First time here? Check out the FAQ!

Ask Your Question
2

Programmatically setting ticks

asked 7 years ago

Paul Bryan gravatar image

updated 2 years ago

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?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 7 years ago

kcrisman gravatar image

updated 7 years ago

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

Preview: (hide)
link

Comments

Okay. thanks. Seems like a thorny issue.

Paul Bryan gravatar imagePaul Bryan ( 7 years ago )

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

kcrisman gravatar imagekcrisman ( 7 years ago )

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: 7 years ago

Seen: 395 times

Last updated: Oct 30 '17