Skip to content

Axes3d plot_surface not supporting masked arrays? #4941

Closed
@maxnoe

Description

@maxnoe

Consider this code:

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colors as colors
from matplotlib import cm
from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, projection='3d')

x, y = np.meshgrid(np.linspace(-1, 1), np.linspace(-1, 1))
z = x**2 + y**2

z[10:20, 10:20] = 0.0

masked_array = np.ma.masked_equal(z, 0.0)
palette = cm.gray
palette.set_over('g', 1.0)
palette.set_under('b', 1.0)
palette.set_bad('r', 1.0)

ax.plot_surface(x,y,masked_array,
    rstride=1,
    cstride=1,
    cmap=palette,
    vmin=-1,
    vmax=1,
    )
plt.show()

The area set to zero should be red, but it isn't. It works on a 2d axis using pcolormesh.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions