This looks incomplete, what's the Exception type?
I tried on my system and it ran OK.
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
Or we could simply use RGB32 where the byte order is correct, and do
without the alpha.
On Wed, 2005-03-16 at 20:27 -0800, matplotlib-devel- email@example.com wrote:
> I just noticed all of the image and colorbar colors are wrong in
> GTKCairo (on linux). When I tried to test on the pure Cairo backend,
> I get
> peds-pc311:~/python/projects/matplotlib/examples> python pcolor_demo.py -dCairo Traceback (most recent call last):
> File "pcolor_demo.py", line 25, 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
> self.canvas.print_figure(*args, **kwargs)
> 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)