Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving the matplotlib 3d rotating plots

Hi does anyone know if there is a way of saving the matplotlib 3d rotating plots in a format which allows them to be still rotated? Perhaps a particular program?

Code is:

from numpy import *
import pylab as p
import mpl_toolkits.mplot3d.axes3d as p3

A=transpose(genfromtxt("Z:/Desktop/Project/bhmqntm-code/RichardsonRK4.csv", unpack=True, delimiter=','))

T=A[:,0]
X=A[:,1]
P=A[:,2]

fig=p.figure()
ax = p3.Axes3D(fig)
ax.scatter(X,P,T,s=1,cmap=cm.jet)
ax.set_xlabel('X')
ax.set_ylabel('P')
ax.set_zlabel('T')
p.show()#I would like this to be something like savefig('Z:/Desktop/Project/bhmqntm-code/plot3d_ex.png') but with a file ending of a program that would save the 3d capability

I'm not sure if a program which does this actually exists but if anyone knows of one it would be very helpful. Thanks.

like image 526
user2023134 Avatar asked Jan 04 '13 06:01

user2023134


People also ask

Can I rotate 3D plot matplotlib?

MatPlotLib with PythonBy creating a 3D projection on the axis and iterating that axis for different angles using view_init(), we can rotate the output diagram.

How do you rotate a 3D scatter plot?

1.2 Rotating the 3D Plot & Key Shortcuts. Click on the 3D plot window and drag the mouse on the plot. This should rotate the surface in the direction you move the mouse about the focus point (the origin, by default). To reset the viewpoint to the original one, press the Home key (fn-left arrow on Mac).


1 Answers

I do not think matplotlib can do it. The solution I found is to make graphs to display them in the browser. For example use plot.ly.

An example: https://plot.ly/python/ipython-notebook-tutorial/#3d-plotting

like image 157
Lucas Avatar answered Oct 13 '22 01:10

Lucas