|
From: Andreas M. <and...@gm...> - 2011-09-22 19:35:30
|
I would like to plot a masked array with plot_surface().
But unlike imshow() which really plots the masked data,
plot_surface() only plots the non-masked data.
How can I plot the masked array?
Ciao
Andreas
import numpy as np
import pylab as mpl
from mpl_toolkits.mplot3d import axes3d
x = np.arange(1,10,1)
y = np.arange(1,10,1)
x,y = np.meshgrid(x,y)
z = x**3 + y**3 - 500
z = np.ma.masked_array(z, z<0)
cm = mpl.cm.jet
ax1 = mpl.subplot(1,2,1, projection='3d')
ax1.plot_surface(x,y,z,
rstride=1, cstride=1, linewidth=0,
cmap=cm)
ax2 = mpl.subplot(1,2,2)
ax2.imshow(z, cmap=cm)
mpl.show()
|