Ask Your Question
2

Tick Marks and Intercepts

asked 2014-02-01 14:56:21 +0200

Slam gravatar image

Help! I'm trying to use Sage to plot x-intercepts, and there seems to be a problem when I try to zoom in too far. E.g. if I execute

plot(1-4*x^2,.4999,.5001,tick_formatter=.0001.n(digits=6))

then I get exactly what I expect, but if I execute

plot(1-4*x^2,.49999,.50001,tick_formatter=.00001.n(digits=7))

then I get this error message:

Traceback (click to the left of this block for traceback) ... Unknown symbol: \verb (at char 0), (line:1, col:1)

Curiously, this seems to be directly related to the fact that my function is crossing the x axis on the domain in question. E.g. if I try

plot(1-4*x^2,1.49999,1.50001,tick_formatter=.00001.n(digits=7))

then everything comes out fine.

Any thoughts on what's going on and/or how to get around it?

Thanks.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-02-01 21:32:38 +0200

kcrisman gravatar image

Good catch. My guess is that this is a matplotlib thing.

That said, the graphics doc suggests this usage of tick_formatter is not really supported - it was intended for symbolic numbers, not floating point ones, though this is a very nice workaround for formatting. The following works (and doesn't look as nice):

plot(1-4*x^2,.49999,.50001,tick_formatter=[.00001.n(digits=7),None])

It turns out that the (Sage) issue is that floating point numbers in RR are also in SR the symbolic ring, which triggers this problem. But in principle this should still work - the problem is that matplotlib is being passed things that turn into -4e^-5. Note that this doesn't work either

plot(1-4*x^2,.50001,.50002,tick_formatter=.00001.n(digits=7))
ValueError: 
\text{\texttt{{-}8e{-}05}}
^
Unknown symbol: \ttext (at char 0), (line:1, col:1)

so the problem is the addition of the \text when we already have the \texttt there.

edit flag offensive delete link more

Comments

Also, sorry this isn't a full answer - it's just as much me debugging out loud. I've opened http://trac.sagemath.org/ticket/15776 for this.

kcrisman gravatar imagekcrisman ( 2014-02-01 21:35:34 +0200 )edit

Certainly no need to apologize; this answer is very helpful. Thanks much, kcrisman.

Slam gravatar imageSlam ( 2014-02-02 10:11:17 +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

Stats

Asked: 2014-02-01 14:56:21 +0200

Seen: 695 times

Last updated: Feb 02 '14