I am having a hard time with something which must be fairly doable: I
would like to plot a simple scalar function on a circular domain.
Consider for instance a trivial modification of one of the online examples:
See pcolor_demo2 for a much faster way of generating pcolor plots
from __future__ import division
from pylab import *
return (1- x/2 + x**5 + y**3)*exp(-x**2-y**2)
# make these smaller to increase the resolution
dx, dy = 0.05, 0.05
x = arange(-1.0, 1.0, dx)
y = arange(-1.0, 1.0, dy)
X,Y = meshgrid(x, y)
Z = func4(X, Y)
print "Z is, ", Z
ax = subplot(111)
im = imshow(Z, cmap=cm.jet)
#ax.set_image_extent(-3, 3, -3, 3)
Now, I would like to plot exactly the same function but on a circular
domain (circle of radius 1 centered at (0,0)).
What is the easiest way of doing that? Some time ago I came across a
similar problem (again, plotting a scalar on a circular domain) and I
came up with this code (thanks to the help I got from the list)
#! /usr/bin/env python
from scipy import *
#print "theta is ", theta
print 'OK up to here'
X = rsin_t.transpose()
Y = rcos_t.transpose()
Z = vel_section.transpose()
velmin = vel_section.min()
velmax = vel_section.max()
print velmin, velmax
levels = arange(velmin, velmax+0.01, 0.1)
pylab.contourf(X, Y, Z, levels, cmap=pylab.cm.jet)
but I have been unable to modify it according to my present needs.
I am not really finding my way through the documentation/examples for
some details (for instance, I am not sure about how to include a
discrete colorbar ranging from 0 to 1 in steps of 0.1 in code 1), but
at the moment this is secondary probably.
Any suggestion is welcome.
Life is what happens to you while you're busy making other plans.