私がやりたいことは簡単です:plt.subplots()
を使って作成したプロットの場合、カラーバーを表示したいと思います。matplotlibストリームプロットのサブプロットカラーバーを表示
だから、これは私が何をすべきかです:docsに示されているものによって
def plotVF(self, u, v):
m = np.sqrt(np.power(u, 2) + np.power(v, 2))
xrange = np.linspace(0, u.shape[1], u.shape[1]);
yrange = np.linspace(0, u.shape[0], u.shape[0]);
x, y = np.meshgrid(xrange, yrange)
mag = np.hypot(u, v)
scale = 1
lw = scale * mag/mag.max()
f, ax = plt.subplots()
h = ax.streamplot(x, y, u, v, color=mag, linewidth=lw, density=3, arrowsize=1, norm=plt.Normalize(0, 70))
ax.set_xlim(0, u.shape[1])
ax.set_ylim(0, u.shape[0])
ax.set_xticks([])
ax.set_yticks([])
cbar = f.colorbar(h, ax=ax)
cbar.ax.tick_params(labelsize=5)
plt.show()
。 は、しかし、私は受信し続ける:
AttributeError: 'StreamplotSet' object has no attribute 'autoscale_None'
をこの例では、唯一のプロットを持っていますが、私は私が直接StreamplotSet
オブジェクトを返しますax.streamplot
plt.colorbar().
[matplotlibのFigureにカラーバーを追加する方法](http://stackoverflow.com/questions/42387471/how-to-add-a-colorbar-to-a-figure-in-matplotlib)の可能な複製) – languitar