I am trying to plot a 3D scatter plot with matplotlib from IPython. 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?
You may want to use
pylab
to get rid of most imports and all the namespaces:See https://plot.ly/ for interactive inline plots.