[SciPy-user] Re: Contour plots
Bryan Cole
bryan.cole at teraview.com
Tue Jun 8 06:43:21 EDT 2004
On Mon, 07 Jun 2004 16:14:35 +0200, Nils Wagner wrote:
> Dear experts,
... doesn't apply to me.
> I want to compute
>
> f(x,y) = log(abs(det(A(x+1j*y))))
>
> over a grid of x,y.
>
> How can I contour the result within scipy or matplotlib ?
>
I struggled with this a while back. You can plot pixmaps from 2D array
data using either scipy.plt or matplotlib, but I don't think you can get
contours. gplt (Gnuplot) can generate contours in 3D plots but I can't see
a way to get a contour plot on 2D axes. Gist can do contours but
scipy.xplt is unix-only and anyway, I couldn't get scipy.xplt to compile
on my FC2-linux machine, so havn't tried it myself.
There is a separate python interface to gist, PyGist
(http://bonsai.ims.u-tokyo.ac.jp/~mdehoon/software/python/pygist-1.5.18a.tar.gz)
which works well. I've just been experimenting with it and it looks the
best out-the-box plotting solution for contours so far. PyGist is also
available for win32. The Gist command set is rather cryptic, however;
matplotlib is much easier for normal 2D graphs IMHO.
There's a PyGist example below.
Bryan
-------------------------
from gist import *
winkill(0)
window(0, wait=1, style='boxed2.gs')
ij = indices((20,20))/20.0 #make a grid
x = ij[0]
y = ij[1]
def f(x,y): #or the function of your choice...
return sin(x**2) + cos(y**2)
z = f(x,y)
plc(z, y, x) #makes contour plot
raw_input() #to stop python exiting
More information about the SciPy-User
mailing list