This looks incomplete, what's the Exception type? I tried
> on my system and it ran OK.
Oops, the complete traceback is below. Maybe my cairo is out of
whack. Are you using CVS?
I tried upgrading my cairo from CVS and got the build error indicated
below. Any ideas? I can post to the cairo mailing list....
> The Cairo colour problem has been noticed and discussed on
> the Cairo mailing list. The cairo.FORMAT_ARGB32 stores each
> 32-bit pixel in native-endian format so on big-endian
> systems it looks like ARGB and on little-endian systems
> (like my PC) it looks like BGRA, I'm not sure if Cairo will
> be updated to 'fix' this or not. A possible workaround is
> to check sys.byteorder, and if its 'little' then get the
> image module / Agg to generate BGRA (I'm not sure if it can
> do this) and even then I think it must be BGRA with
> litte-endian ordering. Or a 'bit-flipping' routine could be
> written to do the same, but seems like a very inefficient
> thing to need to do.
> I guess a good test to start with would be to see if the
> colours are actually correct on a big-endian system. I
> understand the PowerPC is bi- endian - the OS imposes the
> endianness, and that with OS X it is big- endian. So
> perhaps someone with a Mac could test if the colours do
> currently work.
> Or we could simply use RGB32 where the byte order is
> correct, and do without the alpha.
I would vote for dealing with the endianess and different pixel
formats in a platform specific way. The current pixel converters in
and I can provide whatever you need, or you can follow the existing
code and provide them yourself. agg prettty much has a converter for
every format I've heard of.
### Cairo backend traceback
peds-pc311:~/python/projects/matplotlib/examples> python simple_plot.py -dCairo
Traceback (most recent call last):
File "simple_plot.py", line 15, in ?
File "/usr/local/lib/python2.3/site-packages/matplotlib/pylab.py", line 712, in savefig
return fig.savefig(*args, **kwargs)
File "/usr/local/lib/python2.3/site-packages/matplotlib/figure.py", line 457, in savefig
File "/usr/local/lib/python2.3/site-packages/matplotlib/backends/backend_cairo.py", line 647, in print_figure
File "/usr/local/lib/python2.3/site-packages/matplotlib/backends/backend_cairo.py", line 561, in print_figure_fn
if ext == 'png': _save_png (figure, fileObject)
File "/usr/local/lib/python2.3/site-packages/matplotlib/backends/backend_cairo.py", line 583, in _save_png
ctx.set_target_png (fileObject, cairo.FORMAT_ARGB32, width, height)
TypeError: Context.set_target_png() argument 1 must be string, not file
### Cairo CVS build error
make: Entering directory `/home/jdhunter/python/cvs/cairo/src'
if /bin/sh ../libtool --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I.. -I. -I/usr/X11R6/include -I/usr/local/include/libpng12 -I/usr/local/include -I/usr/include/freetype2 -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -fno-strict-aliasing -g -O2 -MT cairo.lo -MD -MP -MF ".deps/cairo.Tpo" -c -o cairo.lo cairo.c; \
then mv -f ".deps/cairo.Tpo" ".deps/cairo.Plo"; else rm -f ".deps/cairo.Tpo"; exit 1; fi
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I. -I/usr/X11R6/include -I/usr/local/include/libpng12 -I/usr/local/include -I/usr/include/freetype2 -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -fno-strict-aliasing -g -O2 -MT cairo.lo -MD -MP -MF .deps/cairo.Tpo -c cairo.c -fPIC -DPIC -o .libs/cairo.lo
In file included from cairo.h:48,
cairo-features.h:42:9: macro names must be identifiers
cairo-features.h:48:9: macro names must be identifiers
cairo-features.h:52:9: macro names must be identifiers
cairo-features.h:56:9: macro names must be identifiers
cairo-features.h:58:9: macro names must be identifiers
cairo-features.h:60:9: macro names must be identifiers
make: *** [cairo.lo] Error 1
peds-pc311:~/python/cvs/cairo> gcc --version
gcc (GCC) 3.3.3
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
peds-pc311:~/python/cvs/cairo> uname -a
Linux peds-pc311.bsd.uchicago.edu 2.4.21-15.0.2.ELsmp #1 SMP Wed Jun 16 22:52:07 EDT 2004 i686 i686 i386 GNU/Linux