SourceForge logo
SourceForge logo
Menu

[matplotlib-devel] Agg large-dataset optimization

From: <ah...@cs...> - 2007年06月28日 00:25:32
Attachments: _backend_agg.cpp
Hi,
I've been plotting data with millions of datapoints, and it takes a long
time for the plot to draw and to rescale with the mouse. I was playing
around with the draw_lines function in the agg backend and sped it up a
bit, maybe others will find it useful. I've attached my optimized version
of _backend_agg.cpp. (just replace the old src/_backend_agg.cpp and
recompile).
The main optimization is to combine sequential lines that are parallel
into a single line to be drawn once. Try "plot(rand(100000),'-')" to see
the change. Resizing and zooming should be faster than before.
This comes at the expense of accuracy since many lines are not drawn. I've
tried to balance out accuracy vs speed to my liking. The main thing to
tweak is a length threshold which I have hardcoded to 0.25. This is the
squared length in pixels that we can move in the direction perpendicular
to the set of parallel lines we are combining and still combine the lines.
(so it can move 0.5 pixels to the side before a new line will be started).
If you set it to 0, you should get the same plots as without my changes.
I also made it skip any lines that are outside of the drawing area.
Hopefully it's not buggy!
Allan

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 によって変換されたページ (->オリジナル) /