[英]Matplotlib does not display interactive graph in Ipython
I am trying to plot a 3D scatter plot with matplotlib from IPython. 我正在尝试使用IPython的matplotlib绘制3D散点图。 I am able to make a plot when I use the inline magic command as follows
我可以按照以下方式使用内联魔术命令进行绘制
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
%matplotlib inline
y = np.arange(10)
x = np.arange(10)
z = np.arange(10)
plt.figure()
ax = plt.axes(projection='3d')
ax.scatter(x,y,z)
But because the plot is inline, it is not interactive and I can not rotate it to the viewing angle I want. 但是因为该图是内联的,所以它不是交互式的,因此无法将其旋转到所需的视角。 When I replace the inline command with
当我将内联命令替换为
%matplotlib
I get 我懂了
<mpl_toolkits.mplot3d.art3d.Path3DCollection at 0x7fb80bf40358>
as output, but no window or graph appears. 作为输出,但没有窗口或图形出现。 If I add
如果我加
plt.show()
to the end of the script, nothing happens. 到脚本末尾,什么都没有发生。 How do I plot an interactive graph in IPython?
如何在IPython中绘制交互式图形?
You may want to use pylab
to get rid of most imports and all the namespaces: 您可能要使用
pylab
摆脱大多数导入和所有名称空间:
%pylab
from mpl_toolkits.mplot3d import Axes3D
y = rand(100)
x = rand(100)
z = rand(100)
ax = subplot(projection='3d')
ax.scatter(x, y, z)
See https://plot.ly/ for interactive inline plots. 请参阅https://plot.ly/了解交互式内联图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.