Ask Your Question

Controlling tick marks in plots

asked 2011-01-08 09:56:43 +0200

calc314 gravatar image

updated 2011-01-08 15:59:02 +0200

kcrisman gravatar image

I'm trying to do a plot and control the tick marks. I'd like to have tick marks on the horizontal axis only at 3 and 6. Here is the code I'm using:


I cannot seem to get the "tick" option to be recognized here by sage. Can anyone help?

Note: I am running Sage 4.4. I am starting to think this is fixed in 4.6. Is that correct?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2011-01-08 16:14:54 +0200

kcrisman gravatar image

You are correct that this should work now in recent versions. Check out link text and search for the word 'ticks'. I don't have your original function $f$, but it shouldn't be hard to create.

sage: plot(x^2, (x, 2, 12), ticks=[[3,6],None])

We need to get this in plot? ... :(

edit flag offensive delete link more

answered 2014-02-01 17:55:03 +0200

ppurka gravatar image

You can use the FormatStrFormatter of matplotlib.

sage: from matplotlib import ticker
sage: TT = ticker.FormatStrFormatter('%.7f')
sage: plot(1-2*x^2,x,.707106,.707107, tick_formatter=TT)
edit flag offensive delete link more


This is something that comes up enough it should be in documentation. If I didn't destroy my Sage build while attempting to upgrade I'd try to review that.

kcrisman gravatar imagekcrisman ( 2014-02-01 21:05:47 +0200 )edit

It's already mentioned in the documentation to look up mpl's ticker documentation.

ppurka gravatar imageppurka ( 2014-02-03 01:24:19 +0200 )edit

No, I mean this specific example, sorry. Because mpl's documentation is sometimes hard to convert to Sage notation.

kcrisman gravatar imagekcrisman ( 2014-02-03 10:50:11 +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


Asked: 2011-01-08 09:56:43 +0200

Seen: 3,539 times

Last updated: Feb 01 '14