Ask Your Question
3

Controlling tick marks in plots

asked 2011-01-08 02:56:43 -0600

calc314 gravatar image

updated 2011-01-08 08:59:02 -0600

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

3 answers

Sort by ยป oldest newest most voted
2

answered 2011-01-08 09:14:54 -0600

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
1

answered 2014-02-01 10:55:03 -0600

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 14:05:47 -0600 )edit

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

ppurka gravatar imageppurka ( 2014-02-02 18:24:19 -0600 )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 03:50:11 -0600 )edit
0

answered 2014-01-31 17:25:06 -0600

Slam gravatar image

How can I get precise tick marks? E.g if I execute

plot(1-2*x^2,x,.707106,.707107)

then ALL of the tick marks on the x axis read 7.071e-1. How can I get the tick marks to write out to seven decimal places? I've tried messing around with the ticks and tick_formatter specifications, but I get either no improvement or an error message.

Can anyone help? Thanks.

edit flag offensive delete link more

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 02:56:43 -0600

Seen: 1,751 times

Last updated: Feb 01 '14