开发者

pylab 2d plotting

开发者 https://www.devze.com 2023-01-06 03:48 出处:网络
开发者_如何学编程im using the pcolor plot in pylab to plot a two dimensional arrays with values between 0 and 1.

开发者_如何学编程im using the pcolor plot in pylab to plot a two dimensional arrays with values between 0 and 1.

Some array entries do not make sense and i want some other color for them in the plot meaning they are not valid.

I tried to call pcolor two times with a differente color map hoping pylab would overlap them, but that didnt work.

How could I do this?

Thanks a lot, Thomas


You can use masked arrays with pcolor. This is, by default, coloured white when plotted. Setting the background colour to something else will change this.

i.e.


# Set the background colour for the axes (green in this example)
matplotlib.rcParams['axes.facecolor'] = 'green'
# Make an identity array
data = np.eye(3)
# Convert to a masked array
masked_data = np.ma.array(data)
# Initialise the mask
masked_data.mask = False
# Now mask the middle data point
masked_data.mask[1,1] = True
# Plot
pcolor(masked_data)
0

精彩评论

暂无评论...
验证码 换一张
取 消