Closed
Description
Bug report
Bug summary
If I make a contour plot, and add some clipping, then when I zoom, then the wrong parts of the plot get clipped.
Code for reproduction
# Paste your code here
import matplotlib
from matplotlib import pyplot
import numpy as np
n=100
tmp = np.random.randn(n,n)
for k in range(2):
tmp = np.cumsum(np.cumsum(tmp,0+k),1-k)
t=np.linspace(-1,1,n)*np.pi
xc=np.cos(t)
yc=np.sin(t)
ax=pyplot.gca()
path = matplotlib.path.Path(np.transpose(np.array([xc, yc])))
patch = matplotlib.patches.PathPatch(path, facecolor='none')
ax.add_patch(patch)
x=np.linspace(-1,1,n)
y=np.linspace(-1,1,n)
cs=pyplot.contour(x,y,tmp,101)
for col in cs.collections:
col.set_clip_path(patch)
ax.plot(xc,yc,'r')
pyplot.show()
Actual outcome
and then I zoom, via the zoom tool on the left half of the figure
Expected outcome
I expect to be able to see all of the contours on the left side that I saw before.
This did work for a previous version of matplotlib. Just tested (and works) with matplotlib 2.2.2 on QtAgg backend on python 2.7.15, as well as matplotlib 3.1.1 on QtAgg backend on python 3.6.7:
zoomed in:
Matplotlib version1
- Operating system: Mac OSX - 10.15.7
- Matplotlib version (
import matplotlib; print(matplotlib.__version__)
): 3.3.4 - Matplotlib backend (
print(matplotlib.get_backend())
): TkAgg - Python version: Python 3.7.10
- Installed via macports
Matplotlib version2
- Operating system:
Linux **** 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
- Matplotlib version (
import matplotlib; print(matplotlib.__version__)
): 3.3.2, 3.3.3 - Matplotlib backend (
print(matplotlib.get_backend())
): Qt5Agg - Python version: Python 3.7.10, 3.7.8
- Installed via conda from
conda-forge
channel