【发布时间】:2014-07-22 22:48:50
【问题描述】:
我正在尝试绘制一个散点图,其中一个点根据滑块调整的参数移动。我需要参数是坐标列表中的位置。我有它,所以绘制了散点图,我可以通过更改位置手动移动点,但是当我尝试实现滑块时,它会显示出来,但不能用于更新绘图。任何帮助都会很棒。到目前为止我所拥有的如下。谢谢。
%pylab
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import animation
def on_change(val):
p=int(val)/1
def chart():
x=[0,0.5,1]
y=[0,0.5,1]
z=[0,0.5,1]
p=0
fig = pyplot.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot([0,0,0,0,0,1,1,0,0,1,1,1,1,1,1,0],[0,1,1,0,0,0,0,0,1,1,0,0,1,1,1,1],[0,0,1,1,0,0,1,1,1,1,1,0,0,1,0,0],c='black',zorder=10)
ax.scatter(x[p],y[p],z[p],zorder=0)
ax.set_xlabel('Width')
ax.set_ylabel('Depth')
ax.set_zlabel('Height')
slider_ax = plt.axes([0.15, 0.05, 0.7, 0.02])
slider = Slider(slider_ax, "min", 0, 2, valinit=1, color='blue')
pyplot.show()
chart()
【问题讨论】:
标签: python matplotlib slider