ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 04 Nov 2016 09:35:14 -0500How to add tick marks or control them in the frame of 3d plots?http://ask.sagemath.org/question/35411/how-to-add-tick-marks-or-control-them-in-the-frame-of-3d-plots/Apparently there is no way to add tick marks or control their spacing in the frame box for 3d plots as you can do it in 2d plots. There is no ticks option.
There is no axis with ticks option. No control over axes labels neither.
I found a way to do so as in the following code (But I cannot interact with the plot as rotating and zooming with the mouse as can be done with sage 3d plots. I would like to have frame tick marks and grid lines, and axis labels as in the graph generated by this code):
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import axes3d
x,y,z=var('x,y,z')
# Next we define the parameters
sigma=10
rho=28
beta=8/3
# The Lorenz equations
lorenz=[sigma*(y-x),x*(rho-z)-y,x*y-beta*z]
# Time and initial conditions
N=250000
tmax=250
h=tmax/N
t=srange(0,tmax+h,h)
ics=[0,1,1]
sol=desolve_odeint(lorenz,ics,t,[x,y,z],rtol=1e-13,atol=1e-14)
X=sol[:,0]
Y=sol[:,1]
Z=sol[:,2]
# Plot the result
from mpl_toolkits.mplot3d import axes3d
from matplotlib import pyplot as plt
# Call the plot function if you want to plot the data
def plot():
fig = plt.figure(1)
ax = fig.add_subplot(111, projection='3d')
ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10)
ax.set_xlabel('X(t)')
ax.set_ylabel('Y(t)')
ax.set_zlabel('Z(t)')
plt.show()
plot()Thu, 03 Nov 2016 22:53:41 -0500http://ask.sagemath.org/question/35411/how-to-add-tick-marks-or-control-them-in-the-frame-of-3d-plots/Answer by slelievre for <p>Apparently there is no way to add tick marks or control their spacing in the frame box for 3d plots as you can do it in 2d plots. There is no ticks option.
There is no axis with ticks option. No control over axes labels neither.</p>
<p>I found a way to do so as in the following code (But I cannot interact with the plot as rotating and zooming with the mouse as can be done with sage 3d plots. I would like to have frame tick marks and grid lines, and axis labels as in the graph generated by this code):</p>
<pre><code>from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import axes3d
x,y,z=var('x,y,z')
# Next we define the parameters
sigma=10
rho=28
beta=8/3
# The Lorenz equations
lorenz=[sigma*(y-x),x*(rho-z)-y,x*y-beta*z]
# Time and initial conditions
N=250000
tmax=250
h=tmax/N
t=srange(0,tmax+h,h)
ics=[0,1,1]
sol=desolve_odeint(lorenz,ics,t,[x,y,z],rtol=1e-13,atol=1e-14)
X=sol[:,0]
Y=sol[:,1]
Z=sol[:,2]
# Plot the result
from mpl_toolkits.mplot3d import axes3d
from matplotlib import pyplot as plt
# Call the plot function if you want to plot the data
def plot():
fig = plt.figure(1)
ax = fig.add_subplot(111, projection='3d')
ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10)
ax.set_xlabel('X(t)')
ax.set_ylabel('Y(t)')
ax.set_zlabel('Z(t)')
plt.show()
plot()
</code></pre>
http://ask.sagemath.org/question/35411/how-to-add-tick-marks-or-control-them-in-the-frame-of-3d-plots/?answer=35414#post-id-35414This will become possible once three.js is used for 3d graphics, instead of jmol.
See [Sage trac ticket #12402](https://trac.sagemath.org/ticket/12402).Fri, 04 Nov 2016 02:38:30 -0500http://ask.sagemath.org/question/35411/how-to-add-tick-marks-or-control-them-in-the-frame-of-3d-plots/?answer=35414#post-id-35414Comment by Masacroso for <p>This will become possible once three.js is used for 3d graphics, instead of jmol.
See <a href="https://trac.sagemath.org/ticket/12402">Sage trac ticket #12402</a>.</p>
http://ask.sagemath.org/question/35411/how-to-add-tick-marks-or-control-them-in-the-frame-of-3d-plots/?comment=35424#post-id-35424Yep, this is a very good idea. Unfortunately my programming skills are low, so I cant contribute to sage :(Fri, 04 Nov 2016 09:35:14 -0500http://ask.sagemath.org/question/35411/how-to-add-tick-marks-or-control-them-in-the-frame-of-3d-plots/?comment=35424#post-id-35424