|
From: <lin...@eu...> - 2013-12-01 15:24:15
|
Hi,
I m trying to plot some data with pcolor. The data should be plotted on a ring. Inside and outside of the ring should be white area. However, now I have black area. Where is my mistake? Minimal working example:
from matplotlib import cm
import matplotlib.pyplot as plt
from pylab import *
import numpy as np
import scipy as sp
X = np.arange(-1.0, 1.01, 0.01)
Y = np.arange(-1.0, 1.01, 0.01)
X, Y = np.meshgrid(X, Y)
[r, R] = [0.25, 1.0]
an = sp.linspace(0,2*sp.pi,100)
fig = plt.figure(1, figsize=(6,6))
ax = fig.add_subplot(111, aspect = 'equal')
Z = X**2 + Y**2
Z[(X**2+Y**2 < r**2) | (X**2+Y**2 > R**2)] = np.ma.masked
cm.hot.set_bad('white', alpha=None)
plot = pcolor(X, Y, Z, cmap=cm.hot)
plt.plot(r*sp.cos(an), r*sp.sin(an), 'k')
plt.plot(R*sp.cos(an), R*sp.sin(an), 'k')
axis([-1.0, 1.0, -1.0, 1.0])
plt.show()
|