SourceForge logo
SourceForge logo
Menu

Re: [matplotlib-devel] CVS - rendering diagonal lines

From: John H. <jdh...@ac...> - 2005年05月22日 18:26:01
>>>>> "Darren" == Darren Dale <dd...@co...> writes:
 Darren> I just noticed that the following script generates a
 Darren> diagonal line that looks like it was drawn with a really
 Darren> unsteady hand:
 Darren> from pylab import frange, plot, show
 Darren> plot(frange(-1,1,.01)*1e10) show()
 Darren> The problem is not noticable for a small number of points,
 Darren> such as plot(frange(-1,1,.5)*1e10). I tried clearing
 Darren> site-packages, rebuilt MPL-0.80, the problem appears to be
 Darren> in CVS.
w/o testing, I'll hazard a guess that this is due to a workaround I
have never been able to figure out with how agg does subpixel
rendering
Try commenting out these lines in _backend_agg.cpp in the draw_lines
function
 thisx = (int)thisx + 0.5;
 thisy = (int)thisy + 0.5;
These lines snap all the x and y points to pixel centers. If you
don't use pixel centers, agg will draw lines of different widths and
heights depending on the subpixel fraction. This is only apparent for
vertical and horizontal lines, generally, but is glaring for ticks and
grid lines. In the past, I've added a hack to only do snap to pixel
for horizontal and vertical lines with 2 points, which fixes the
special case problems of ticks and grids
I raised this issue with Maxim on the agg mailing list
http://sourceforge.net/mailarchive/message.php?msg_id=8575544
and he responded by writing this page
http://antigrain.com/tips/line_alignment/line_alignment.agdoc.html
which I still haven't been able to digest sufficiently in a way that
fixes this problem generally.
I reinstated in CVS a temporary hack which only does the snapto pixel
trick for len(2) lines. Should work well for most use cases. Give it
a try.
JDH

View entire thread

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /