【发布时间】:2018-10-11 19:56:54
【问题描述】:
我正在 IPython 笔记本中的 matplotlib 中制作一个简单的 3D 动画,但我的观点正在神秘地改变 alpha 值:
import numpy as np
import matplotlib.pyplot as plt
import mpl_toolkits.mplot3d.axes3d as p3
import matplotlib.animation as animation
from IPython.display import HTML
import requests
%matplotlib inline
requests.get('https://gist.github.com/duhaime/023897b9bda70e7728c7db9792a11bd3/raw/b632e2ea9fb693f303908f546a684a3afcc329c0/data.npy')
X = np.load('data.npy')
def update_points(time, points):
arr = np.array([[ X[time][i][0], X[time][i][1] ] for i in range(int(X.shape[1]))])
points.set_offsets(arr) # set x, y values
points.set_3d_properties(X[time][:,2][:], zdir='z') # set z value
def get_plot():
fig = plt.figure()
ax = p3.Axes3D(fig)
ax.set_xlim(-10,10)
ax.set_ylim(-10,10)
ax.set_zlim(-10,10)
points = ax.scatter(X[0][:,0][:], X[0][:,1][:], X[0][:,2][:]) # x,y,z vals
return animation.FuncAnimation(fig,
update_points,
200, # steps
interval=100, # how often to refresh plot
fargs=(points,),
blit=False
).to_jshtml()
HTML(get_plot())
有谁知道为什么点的 alpha 值会发生变化?其他人可以提供的任何建议都会非常有帮助!
【问题讨论】:
标签: python numpy matplotlib jupyter-notebook ipython