Reputation: 567
If there is arrays of x, y, and z coordinates. I don't mean to show a static 2d plot, which can be drawn by
plot(x, y)
I mean
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.plot(x, y, z, label='parametric curve')
plt.show()
which matplotlib function can change the view to side-view? So that I can add buttons for the matplotlib GUI, on which when user click, the 3d plot will be drawn as top-view/left-view/... and the user can still use mouse to rotate the plot in a 3d way later, just like what we can do in CAD software.
thanks
Upvotes: 5
Views: 6397
Reputation: 40697
If I understand your question, you are looking for the function Axes3D.view_init
view_init(elev=None, azim=None)
Set the elevation and azimuth of the axes.
This can be used to rotate the axes programatically.
‘elev’ stores the elevation angle in the z plane. ‘azim’ stores the azimuth angle in the x,y plane.
if elev or azim are None (default), then the initial value is used which was specified in the Axes3D constructor.
Upvotes: 4
Reputation: 20080
This depends on what UI toolkit you plan to use. Matplotlib could use multiple backends, among those are file backend, Qt4 backend, Qt5 backend, Wx toolkit backend etc.
If you decide to make UI in python using Qt backend, there is an example how to embed matplotlib plot using Qt backend into Qt canvas: https://matplotlib.org/gallery/user_interfaces/embedding_in_qt_sgskip.html
Similar embedding could be done for Wx toolkit. I would also guess you could use matplotlib JS backend like http://mpld3.github.io/, and proceed with making UI in Javascript
Upvotes: 0