Skip to content

Plotting masked arrays with plot_surface() #487

@AndreasMatthias

Description

@AndreasMatthias

I would be nice if plot_surface() could plot masked arrays. Unlike imshow() which really plots the masked data,
plot_surface() only plots the non-masked data.
Here is an example:

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()

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions