我有一个矩阵,比如:
import numpy as np
import seaborn as sns; sns.set()
import matplotlib.pyplot as plt
%matplotlib inline
originalPoints = np.asarray([[1,2,3,4,5,6],[2,4,6,8,10,12]])
newPoints = np.asarray([[1,2,3,4,5,6],[2,4,6,8,10,12]]) + 20
plt.scatter(originalPoints[0,:],originalPoints[1,:], color='red');
plt.scatter(newPoints[0,:],newPoints[1,:], color='blue');
这给了我:
我试图生成一个gif/动画,显示点沿着从红色到蓝色的平滑路径移动。我一直在尝试使用类似于what is discussed here和scipy的interpolate discussed here的东西,但我似乎搞不懂。在
任何帮助都会很好。在
好处:一个解决方案,也将在三维工作
编辑:为了清楚起见,我想要的是一些非线性平滑的路径,沿着这个路径每个蓝点移动到红点。注-上面的例子是虚构的。实际上只有一堆蓝点和一堆红点。考虑在两个不同的散点图之间设置动画。在
您只需在每对点之间创建一条线性路径;将其与^{} 组合起来就可以了
编辑:编辑后的问题现在要求一个非线性插值;将
^{pr2}$update_plot
替换为你得到了
编辑2:关于下面注释中关于颜色插值的查询,您可以通过^{} ;具体地说,将上面的
update_plot
替换为我们最终
关于“奖金”:3D的情况基本上是相似的
编辑下面关于如何分阶段执行此操作的注释:可以通过将the composition of paths直接合并到
update_plot
中来实现这一点:相关问题 更多 >
编程相关推荐