Ask Your Question
4

Controlling tick marks in plots

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

calc314 gravatar image

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

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:

p=plot(f(v),(v,2,12),detect_poles='show',ymin=-2,ymax=50)
p+=text('vc',(3,-1.5),color='black')
p+=text('2vc',(6,-1.5),color='black')
show(p)

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
2

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

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
2

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

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

Comments

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 +0100 )edit

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

ppurka gravatar imageppurka ( 2014-02-03 01:24:19 +0100 )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 +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

Stats

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

Seen: 3,955 times

Last updated: Feb 01 '14