On 11/8/10 5:00 PM, Karsten wrote:
I am a beginner using sage, and I have encountered a problem using the
plot function. Plotting a simple sine or cosine function is not very
precise:

t=var('t')
v=plot(sin(t),-pi,pi

The function is clearly positive in t=-pi, where it should be zero.
The mistake becomes even more clear when setting line thickness to 99:

t=var('t')
v=plot(sin(t),-pi,pi,thickness=99)

In this case when x=0 the line is crossing 1 in the upper side and not
-1 in the lower side.

This problem occurs in all functions i have encountered so far, as if
the function is displayed 1 or 2 pixels off. It's even worse when
plotting arrows:

plot(arrow((0,0), (2,3)))

Here the arrow is clearly not starting in (0,0) as it should.

Is there a solution for this kind of problem?


Yes. It's a tradeoff between sharper graphics and rounding issues with pixels in plots. IIRC, the basic issue is that horizontal and vertical lines are "snapped" to the nearest pixel, so that they aren't anti-aliased and fuzzy.

This has been investigated quite a bit at:

http://trac.sagemath.org/sage_trac/ticket/7808

In short, you can do:

import matplotlib
matplotlib.rcParams['path.snap'] = False

This will make horizontal and vertical lines (like the axes) not snap to the nearest pixel. Things may be a bit fuzzier, though.

Thanks,

Jason

--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to