Closed
Description
Bug report
Bug summary
If I attempt to make a contour plot with data that is entirely below the lowest level, and the data has a field of zeros around it, I get an unexpected contour between the zeros and anything positive.
Code for reproduction
import numpy as np
import matplotlib.pyplot as plt
y = np.linspace(-10, 10, 20)
x_2d, y_2d = np.meshgrid(y, y)
data = np.cos(x_2d * np.pi/10.) + np.cos(y_2d * np.pi/10.)
np.place(data, data < 0., 0.)
levels = [3, 6]
colors = ['b', 'r']
plt.contour(data, levels=levels, colors=colors)
plt.show()
Actual outcome
Expected outcome
The plot should be blank, which is what happens if the call to np.place
is skipped.
Matplotlib version
- Operating system: RHEL7.9
- Matplotlib version (
import matplotlib; print(matplotlib.__version__)
): 3.4.1 - Matplotlib backend (
print(matplotlib.get_backend())
): Qt5Agg - Python version: 3.8.8
- Jupyter version (if applicable): N/A
- Other libraries: numpy 1.20.2