Hi all,
I just discovered that attempting to plot a complex array using imshow()
results in a not-very-helpful traceback (attached). Would it be worth
catching this on the actual call to imshow() and raising a more
transparent error? (The test script, slightly modified from Gaƫl
Varoquaux's pyreport examples is attached and makes a beautiful plot and
is also attached.)
-Andrew
Traceback (most recent call last):
File "mpl-test.py", line 27, in <module>
savefig('x.png')
File
"/home/astraw/py2.5-linux-x86_64/lib/python2.5/site-packages/matplotlib/pyplot.py",
line 271, in savefig
return fig.savefig(*args, **kwargs)
File
"/home/astraw/py2.5-linux-x86_64/lib/python2.5/site-packages/matplotlib/figure.py",
line 947, in savefig
self.canvas.print_figure(*args, **kwargs)
File
"/home/astraw/py2.5-linux-x86_64/lib/python2.5/site-packages/matplotlib/backend_bases.py",
line 1085, in print_figure
**kwargs)
File
"/home/astraw/py2.5-linux-x86_64/lib/python2.5/site-packages/matplotlib/backends/backend_gtkagg.py",
line 103, in print_png
return agg.print_png(filename, *args, **kwargs)
File
"/home/astraw/py2.5-linux-x86_64/lib/python2.5/site-packages/matplotlib/backends/backend_agg.py",
line 300, in print_png
FigureCanvasAgg.draw(self)
File
"/home/astraw/py2.5-linux-x86_64/lib/python2.5/site-packages/matplotlib/backends/backend_agg.py",
line 256, in draw
self.figure.draw(self.renderer)
File
"/home/astraw/py2.5-linux-x86_64/lib/python2.5/site-packages/matplotlib/figure.py",
line 791, in draw
for a in self.axes: a.draw(renderer)
File
"/home/astraw/py2.5-linux-x86_64/lib/python2.5/site-packages/matplotlib/axes.py",
line 1368, in draw
im.draw(renderer)
File
"/home/astraw/py2.5-linux-x86_64/lib/python2.5/site-packages/matplotlib/image.py",
line 226, in draw
im = self.make_image(renderer.get_image_magnification())
File
"/home/astraw/py2.5-linux-x86_64/lib/python2.5/site-packages/matplotlib/image.py",
line 176, in make_image
x = self.to_rgba(self._A, self._alpha)
File
"/home/astraw/py2.5-linux-x86_64/lib/python2.5/site-packages/matplotlib/cm.py",
line 76, in to_rgba
x = self.cmap(x, alpha=alpha, bytes=bytes)
File
"/home/astraw/py2.5-linux-x86_64/lib/python2.5/site-packages/matplotlib/colors.py",
line 460, in __call__
lut.take(xa, axis=0, mode='clip', out=rgba)
TypeError: array cannot be safely cast to required type
from numpy import *
from pylab import *
#from pylab import imshow
#!
#! Some graphical explorations of the Julia sets with python and pyreport
#!#########################################################################
#$
#$ We start by defining a function J:
#$ \[ J_c : z \rightarrow z^2 + c \]
#$
def J(c):
return lambda z : z**2 + c
[x,y] = ogrid[ -1:1:0.002, -1:1:0.002 ]
z = x + y *1j
#! If we study the divergence of function J under repeated iteration
#! depending on its inital conditions we get a very pretty graph
threshTime = zeros_like(z)
for i in range(40):
z = J(0.285)(z)
threshTime += z*conj(z) > 4
figure(0)
axes([0,0,1,1])
axis('off')
imshow(threshTime)
bone()
savefig('x.png')
show()
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel