Ask Your Question

# Programmatically setting ticks

I currently generate an array of plots by something like:

u = var('u')
array = [vector([u, cos(i*u)]) for i in range(0, 3)]
P = [parametric_plot(p, (u, 0, 2*pi)) for p in array]


Then I can set the axes of individual plots by

P[1].axes(False)


I plot it via

g = graphics_array(P)
g.show()


This produces a plot with three graphs where the second graph has no axes. Great.

I can set ticks when showing a plot:

p = P[1]
p.show(ticks=[[0, 2*pi], [p.ymin(), p.ymax()]], tick_formatter=[pi,None])


But I can't seem to find how to set them programmatically as with the axes above. I have tried accessing the underlying matplotlib object by

m = p.matplotlib


I don't see how to set the ticks there.

Does anyone know how I can set the ticks for plots individually?

edit retag close merge delete

## 1 Answer

Sort by ยป oldest newest most voted

Technically, in matplotlib the ticks are an attribute of the shown object, not the object itself. There is something called an Axes object to which ticks belong. That said, you can pass the ticks this way:

u = var('u')
array = [vector([u, cos(i*u)]) for i in range(0, 3)]
P = [parametric_plot(array[i], (u, 0, 2*pi),ticks=[[0,i],[0,i]]) for i in range(len(array))]
g = graphics_array(P)
g


but you will see this doesn't give what you want either; only the last one has the custom ticks. The problem is that we haven't found a good way to resolve https://trac.sagemath.org/ticket/10466 or https://trac.sagemath.org/ticket/10657

more

## Comments

Okay. thanks. Seems like a thorny issue.

( 2017-11-06 09:25:20 +0200 )edit

Yeah, sorry we don't have a better answer for this.

( 2017-11-09 21:12:48 +0200 )edit

## Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

## Stats

Asked: 2017-10-30 09:59:18 +0200

Seen: 360 times

Last updated: Oct 30 '17