Dear experts, I am interested in a plot of equipotential
> curves. If desired, the regions between contours should be
> shaded or colored to indicate their magnitude.
> Is this feature already available in matplotlib ? A small
> example will be appreciated.
There is no contour per se, but you can use imshow or pcolor with a
custom colormap that has only few levels to emulate one, as shown in
this screenshot and example below
http://nitace.bsd.uchicago.edu:8080/files/share/poormans_contour.png
We are interested in developing a real contour function however, which
also provides contour lines, etc, as mentioned on
http://matplotlib.sourceforge.net/goals.html.
Cheers,
John Hunter
#!/usr/bin/env python
from matplotlib.matlab import *
def bivariate_normal(X, Y, sigmax=1.0, sigmay=1.0,
mux=0.0, muy=0.0, sigmaxy=0.0):
"""
Bivariate gaussan distribution for equal shape X, Y
Bivariate Normal Distribution -- from Wolfram MathWorld
"""
Xmu = X-mux
Ymu = Y-muy
rho = sigmaxy/(sigmax*sigmay)
z = Xmu**2/sigmax**2 + Ymu**2/sigmay - 2*rho*Xmu*Ymu/(sigmax*sigmay)
return 1.0/(2*pi*sigmax*sigmay*(1-rho**2)) * exp( -z/(2*(1-rho**2)))
delta = 0.01
x = arange(-3.0, 3.0, delta)
y = arange(-3.0, 3.0, delta)
X,Y = meshgrid(x, y)
Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
# difference of Gaussians
cmap = ColormapJet(10) # only 10 levels for discrete color steps
im = imshow(Z2-Z1, cmap)
# set the interpolation method: 'nearest', 'bilinear', 'bicubic' and much more
im.set_interpolation('bilinear')
axis('off')
#savefig('test')
show()