ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 04 Nov 2016 04:53:41 +0100How to add string tick labels to 2D plots?https://ask.sagemath.org/question/9945/how-to-add-string-tick-labels-to-2d-plots/Hi folks, i want to add string tick labels to a 2D plot, e.g. `['$100', '$200', '$300']` on the x-axis instead of the ticks `[1, 2, 3]`. I see from [http://stackoverflow.com/questions/5439708/python-matplotlib-creating-date-ticks-from-string](http://stackoverflow.com/questions/5439708/python-matplotlib-creating-date-ticks-from-string) that i can do this with matplotlib via
from matplotlib import pyplot as plt
plt.plot([1,2,3],[3,4,3])
ax = plt.gca()
ax.set_xticks([1,2,3])
ax.set_xticklabels(['$100','$200','$300'])
Is there a Sage way to accomplish the same thing?
Personally, i find Sage plotting commands more user-friendly than matplotlib commands.araichevSun, 24 Mar 2013 18:48:21 +0100https://ask.sagemath.org/question/9945/How to add tick marks or control them in the frame of 3d plots?https://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()galmeida2007Fri, 04 Nov 2016 04:53:41 +0100https://ask.sagemath.org/question/35411/How to change position of the axes values of a Sage plot.https://ask.sagemath.org/question/33387/how-to-change-position-of-the-axes-values-of-a-sage-plot/ I am plotting 2D functions on Sage, and I would like to move the values displayed along the $y$ axis (the ticks) from the left of the axis to the rigth, because they bother me there. I had a look and I think this can be done in Python with matplotlib (using `set_tick_params()` or `set_ticks_position()`) which is included in Sage, but I am not sure of how to combine a `region_plot()` from Sage with this axis modification.
¿Anyway to do what I am saying? I can't include an example of what I am saying because I don't have enough Karma to add a figure or link...iiprThu, 12 May 2016 18:01:18 +0200https://ask.sagemath.org/question/33387/Tick labels in a matrix plothttps://ask.sagemath.org/question/32182/tick-labels-in-a-matrix-plot/I want to plot the following matrix `m` with k and l in {-2, ..., 2}:
m = [[k+l for k in range(-2,3)] for l in range(-2,3)]
with `matrix_plot`:
m_plot = matrix_plot(m, origin='lower')
The ticks on both axes are automatically set to {0 , ... , 5}, but I want the ticks to be {-2, -1, 0, 1, 2} on both axes.
I could not figure out how to do this.Philosophiæ NaturalisWed, 13 Jan 2016 11:37:55 +0100https://ask.sagemath.org/question/32182/