Ask Your Question

Programmatically setting ticks

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

Paul Bryan gravatar image

updated 2023-01-09 23:59:43 +0200

tmonteil gravatar image

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


I plot it via

g = graphics_array(P)

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][[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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-10-30 15:50:04 +0200

kcrisman gravatar image

updated 2017-10-30 15:50:16 +0200

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)

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 or

edit flag offensive delete link more


Okay. thanks. Seems like a thorny issue.

Paul Bryan gravatar imagePaul Bryan ( 2017-11-06 09:25:20 +0200 )edit

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

kcrisman gravatar imagekcrisman ( 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

Question Tools

1 follower


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

Seen: 331 times

Last updated: Oct 30 '17