Ask Your Question
2

Programmatically setting ticks

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

Paul Bryan gravatar image

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

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

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

1 Answer

Sort by ยป oldest newest most voted
1

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

kcrisman gravatar image

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

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

edit flag offensive delete link more

Comments

Okay. thanks. Seems like a thorny issue.

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

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

kcrisman gravatar imagekcrisman ( 2017-11-09 21:12:48 +0100 )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

Stats

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

Seen: 386 times

Last updated: Oct 30 '17