> With antialiasing off, the performance is superb!.. I plot
> 500,000 points in ~4-5 seconds.. The visual quality of the
> graphs is (naturally) inferior to the antialiased
> counterparts, but the software is now feasible for my
> purposes.
Glad to hear it... The next big performance boost will come from some
frontend refactoring along the lines Perry discussed, but I'm glad to
hear it's usable for you now.
> 1) Seems like setting 'lod' to true does not improve
> performance? I would imagine it should, because it limits
> the amount of points used. What am I missing?
I'll look into this further. In the special case of EEG (128 channels
plotted simultaneously over the same time axis), I do see significant
benefits but I cache the sampling indexes from one line to the next.
It may be that for single lines the time it takes to do the
subsampling balances the time it takes to plot them in a fast backend.
> 2) Is there any way to make the graphs look "prettier"?
> They really look quite OK but in some cases having a little
> more detail would be nice. Is it possible specify just how
> much antialiasing is needed? Are there any other "visual
> enchantment options" that can be set, and will not impact
> performace too much?
Well, fortunately for you, I just finished the agg backend this
morning. This backend draws antialiased lines as fast as GD draws
unaliased lines. I still don't have support for turning off
antialiasing in agg, but it sounds like you want to have it. Also, it
doesn't suffer from a known color allocation and fill bug that GD has.
See install instructions at the end of this email.
> 3) When I do:
plot1 = plot(arange(10000), arange(20000,30000))
lod, aa = False, False
set(l, 'lod', lod, 'antialiased', aa)
This code isn't correct. plot returns a list of lines. The set
command should operate on that list of lines. It applies only to the
lines returned. So *you can* apply antialising with respect to one
set of lines and not another, in the same axes
lines1 = plot(arange(10000), arange(20000,30000))
set(lines1, 'antialiased', False)
lines2 = plot([1,2,3]) # a small plot
set(lines2, 'antialiased', True)
Now lines1 is aliased and lines2 is antialiased.
> I have been playing around with the dpi setting a
> little. Is it supposed to change the size of the image
> and/or the resolution??
The figure size in pixels is determined by the figsize parameter and
dpi.
width, height = figsize
width *= dpi
height *= dpi
Everything scales with DPI, line width, text size, dash spacing,
etc.. So the answer to your question is: both figure size and
resolution increase with dpi. If you want to change figure size w/o
changing resolution, change the figsize argument to figure.
The agg backend
Warning: you will be the first agg crash test dummy. I just ran a
suite of examples across all backends and agg was the fastest - it's
even faster than template, which does no rendering or filesaving!
And in my opinion it also produced the highest quality output.
Features that are implemented
* capstyles and join styles
* dashes
* linewidth
* lines, rectangles, ellipses, polygone
* clipping to a rectangle
* output to RGBA and PNG
* alpha blending
* DPI scaling - (dashes, linewidths, fontsizes, etc)
* freetype1
TODO:
* use ttf manager to get font - right now I just use Vera
INSTALLING
Grab the latest matplotlib from
http://nitace.bsd.uchicago.edu:8080/files/share/matplotlib-0.50l.tar.gz
REQUIREMENTs
python2.2+
Numeric 22+
agg2 (see below)
freetype 1
libpng
libz ?
Install AGG2 (cut and paste below into xterm should work)
wget http://www.antigrain.com/agg2.tar.gz
tar xvfz agg2.tar.gz
cd agg2
make
(Optional) if you want to make the examples:
cd examples/X11
make
Installing backend_agg
Edit setup.py: change aggsrc to point to the agg2 src tree and
replace if 0: with if 1: in the backend_agg section
Then just do the usual thing: python setup.py build
Please let me know if you encounter build problems, and tell me
platform, gcc version, etc... Currently the paths in setupext.py
assume as linux like filesystem (eg X11 include dir, location of
libttf, etcc) so you may need to tweak these. But if I recall
correctly, we're both on RHL9 so you shouldn't have a problem.
Using agg backend
python somefile.py -dAgg
or
import matplotlib
matplotlib.use('Agg')
Let me know how it works out! Note also that backend agg is the first
backend to support alpha blending; see scatter_demo2.py.
JDH