You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code below can run smoothly without any errors, but it returns no figure when I run it as a script.
If I run it in ipython command, it's fine.
Wired!!
For other script, my python is also fine.
No ideas.
importnumpyasnpfrommpl_toolkits.mplot3dimportAxes3Dimportmatplotlib.pyplotaspltimportmatplotlibasmpldefcolorMapper(data):
#_this helper function returns mapper that will normalize#_the colors in your dataset for plottingminima=min(data)
maxima=max(data)
norm=mpl.colors.Normalize(vmin=minima,
vmax=maxima,
clip=True)
mapper=mpl.cm.ScalarMappable(norm=norm)
returnnorm, mapperfig=plt.figure()
ax=fig.add_subplot(111, projection='3d')
xs= [1, 1, 1, 1, 1, 1, 1, 1]
ys= [1, 1, 1, 1, 2, 2, 2, 2]
zs= [1, 2, 3, 4, 1, 2, 3, 4]
data= [1, 2, 3, 4, 1, 2, 3, 4]
norm, mapper=colorMapper(data)
forx, y, z, datinzip(xs, ys, zs, data):
ax.scatter(x, y, z, color=mapper.to_rgba(dat),s=dat*10)
plt.savefig('foo.png')
fig.show()
The text was updated successfully, but these errors were encountered:
Use plt.show instead of fig.show(). plt.show blocks and runs the GUI event loop, fig.show does not.
Compare
importmatplotlib.pyplotaspltfig, ax=plt.subplots()
ax.plot(range(3))
print('done creating artists')
# ## Switch which of these are commented outplt.show()
# fig.show()print('done showing')
matplotlib version 1.5.1; Py 2.7.11; OSX
The code below can run smoothly without any errors, but it returns no figure when I run it as a script.
If I run it in ipython command, it's fine.
Wired!!
For other script, my python is also fine.
No ideas.
The text was updated successfully, but these errors were encountered: