Skip to content

Inconsistent Corner Masking w/ plot_surface #16470

Closed

Description

@b0ndman

Inconsistent Corner Masking w/ plot_surface

plot_surface inconsistently corner masks and even may not plot certain values when given a non-rectangular array.

import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
from mpl_toolkits.mplot3d import axes3d

x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
y = [1, 2, 3, 4, 5, 6, 7, 8]

X, Y = np.meshgrid(x, y)

matrix = np.array([[np.nan, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                    [np.nan, 1.0, 2.0, 3.0, 4.0, 4.0, 4.0, 3.0, 2.0, 1.0, 1.0],
                    [np.nan, np.nan, 4.0, 5.0, 6.0, 8.0, 6.0, 5.0, 4.0, 3.0, np.nan],
                    [np.nan, np.nan, 7.0, 8.0, 11.0, 12.0, 11.0, 8.0, 7.0, np.nan, np.nan],
                    [np.nan, np.nan, 8.0, 9.0, 10.0, 16.0, 10.0, 9.0, 10.0, 7.0, np.nan],
                    [np.nan, np.nan, np.nan, 12.0, 16.0, 20.0, 16.0, 12.0, 11.0, np.nan, np.nan],
                    [np.nan, np.nan, np.nan, np.nan, 22.0, 24.0, 22.0, 20.0, 18.0, np.nan, np.nan],
                    [np.nan, np.nan, np.nan, np.nan, np.nan, 28.0, 26.0, 25.0, np.nan, np.nan, np.nan]])
maskMat = np.ma.masked_invalid(matrix)
print(maskMat)

fig = plt.figure()
ax = fig.gca(projection = '3d')
normC = mpl.colors.Normalize(vmax = maskMat.max(), vmin = maskMat.min())
colors = mpl.cm.plasma(normC(maskMat))
surf = ax.plot_surface(X, Y, maskMat, norm = normC)
plt.show()

Actual outcome
Corner masking only happens on the left and not on the right:
bug report

A case where a point is dropped:
bug report II

Expected outcome
Corner masking consistently, and/or a way to control it like in contourf

Matplotlib version

  • Operating system: Windows 10
  • Matplotlib version: 3.1.3
  • Matplotlib backend (print(matplotlib.get_backend())): TkAgg
  • Python version: 3.7.3
  • Other libraries: Numpy 1.18.1

Matplotlib was installed via PyCharm Community edition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions