New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: error plotting z-axis array with np.nan -- does not plot with cmap option (surface plot) #20905
Comments
This appears to fixed on the default branch and v3.5.x import matplotlib
import matplotlib.pyplot as plt
import numpy as np
xx = np.linspace(0.0, 100, 101)
yy = np.linspace(0.0, 100, 101)
zz = np.linspace(0.0, 0, 1)
x, y, z = np.meshgrid(xx, yy, zz, indexing="ij")
z[30][30] = np.nan
fig = plt.figure(figsize=(13, 13))
ax = fig.add_subplot(111, projection="3d")
ax.plot_surface(
x[:, :, 0],
y[:, :, 0],
z[:, :, 0],
rstride=1,
cstride=1,
cmap="coolwarm",
edgecolor="none",
)
ax.set_title(f"Matplotlib: {matplotlib.__version__}")
# the cmap option causes a blank plot
plt.show() You can test out the 3.5 beta release now if you want: pip install matplotlib --upgrade --pre |
I am going to close this as fixed. I do not think we are going to have another 3.4.x release so even if we tracked down the fix for this and backported it (assuming it is a small enough change to backport), we would likely not release it. That said, if someone did the work to track this down we could consider it. |
@tacaswell appreciate it |
This is likely due to the new feature that was worked on recently.
plot_surface() hasn't supported NaNs until that new feature that was added
earlier this month (or last month, I think).
…On Wed, Aug 25, 2021 at 6:29 PM Simon Beer ***@***.***> wrote:
@tacaswell <https://github.com/tacaswell> appreciate it
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#20905 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACHF6HZXY7DUMGK6U4WCCLT6VVEHANCNFSM5C2BVRSQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email>
.
|
Ah, then that is definitely not a back-port candidate! |
Bug summary
The bug I have is that when trying to plot a surface plot, and have some z axis values as np.nan, if the cmap option is included in the construction of the surface plot, the plot shows up as an empty space.

Code for reproduction
Actual outcome
Expected outcome
The plot should just be a flat surface plot 100 x 100 with a np.nan value at (30,30)
Operating system
Windows 10 / Ubuntu
Matplotlib Version
3.4.2
Matplotlib Backend
No response
Python version
3.8.10
Jupyter version
No response
Other libraries
No response
Installation
pip
Conda channel
No response
The text was updated successfully, but these errors were encountered: