<p dir="auto">In matplotlib 3.5.1 on Linux (arch and opensuse) pcolormesh is causing some extreme slowdowns. When I try to zoom or pan inside the window, reactions from the mouse are very slow, such that the drawn zoom indicator is &gt;1s delayed and the window/notebook freezes.</p>
<p dir="auto">The extend varies somewhat by backend. Using the <code class="notranslate">%matplotlib notebook</code> backend in jupyter notebook, freezes as soon as one tries to zoom, and the kernel has to be restarted. Using Qt5Agg with ipython from the terminal, also freezes immediately. With the Gtk3Agg backend the window does not fully freeze but the zoom indicator etc. are extremely laggy.</p>
<p dir="auto">I checked with <code class="notranslate">pcolor</code> and <code class="notranslate">pcolorfast</code> as well as <code class="notranslate">imshow</code> and all work fine.</p>
<p dir="auto">Test case:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import matplotlib.pyplot as plt
import numpy as np
  
x = np.linspace(-5,5,512)
X,Y = np.meshgrid(x,x)
g = np.exp(-(X**2+Y**2)/2)

plt.figure()
ax = plt.subplot(111)
plt.pcolormesh(X,Y,g)
plt.show()"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>
<span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
  
<span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">linspace</span>(<span class="pl-c1">-</span><span class="pl-c1">5</span>,<span class="pl-c1">5</span>,<span class="pl-c1">512</span>)
<span class="pl-v">X</span>,<span class="pl-v">Y</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">meshgrid</span>(<span class="pl-s1">x</span>,<span class="pl-s1">x</span>)
<span class="pl-s1">g</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">exp</span>(<span class="pl-c1">-</span>(<span class="pl-v">X</span><span class="pl-c1">**</span><span class="pl-c1">2</span><span class="pl-c1">+</span><span class="pl-v">Y</span><span class="pl-c1">**</span><span class="pl-c1">2</span>)<span class="pl-c1">/</span><span class="pl-c1">2</span>)

<span class="pl-s1">plt</span>.<span class="pl-en">figure</span>()
<span class="pl-s1">ax</span> <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-en">subplot</span>(<span class="pl-c1">111</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">pcolormesh</span>(<span class="pl-v">X</span>,<span class="pl-v">Y</span>,<span class="pl-s1">g</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()</pre></div>
<p dir="auto">Run and select the zoom button in the opened window. If using Qt5Agg the window (and terminal) freezes, CTRL-C only works with very long delay.</p>
<h3 dir="auto">Bug summary</h3>
<p dir="auto">After updating to mpl 3.5.0 my program hangs after plotting with pcolormesh(), no error messages. It works fine witl mpl 3.3.3. When I reduce the nx,ny values in my program it works fine.</p>
<h3 dir="auto">Code for reproduction</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import numpy as np
    import matplotlib.pyplot as plt
    import cartopy.io.img_tiles as cimgt
    import cartopy.crs as ccrs

    fig, ax1 = plt.subplots(num=&quot;TestXX&quot;, figsize=(30/2.54, 25/2.54))
    
    #add a map of the Netherlands
    request = cimgt.OSM()
    ax1=plt.axes(projection=request.crs)
    ax1.set_extent([3.25, 7.35, 50.45, 53.55],ccrs.PlateCarree())
    ax1.add_image(request, 10)
    
    #create a rectangular grid a little smaller than the map
    #with cell sizes of 0.01 degree filled with random values
    nx=400
    ny=300
    xedges=np.linspace(3.3, 7.3, nx)
    yedges=np.linspace(50.5, 53.5, ny)
    zvalues=np.random.random((nx, ny))
    
    ax1.pcolormesh(xedges, yedges, zvalues.T ,\
                   alpha=0.3, shading='auto', transform=ccrs.PlateCarree())
        
    plt.show()"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
    <span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>
    <span class="pl-k">import</span> <span class="pl-s1">cartopy</span>.<span class="pl-s1">io</span>.<span class="pl-s1">img_tiles</span> <span class="pl-k">as</span> <span class="pl-s1">cimgt</span>
    <span class="pl-k">import</span> <span class="pl-s1">cartopy</span>.<span class="pl-s1">crs</span> <span class="pl-k">as</span> <span class="pl-s1">ccrs</span>

    <span class="pl-s1">fig</span>, <span class="pl-s1">ax1</span> <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-en">subplots</span>(<span class="pl-s1">num</span><span class="pl-c1">=</span><span class="pl-s">"TestXX"</span>, <span class="pl-s1">figsize</span><span class="pl-c1">=</span>(<span class="pl-c1">30</span><span class="pl-c1">/</span><span class="pl-c1">2.54</span>, <span class="pl-c1">25</span><span class="pl-c1">/</span><span class="pl-c1">2.54</span>))
    
    <span class="pl-c">#add a map of the Netherlands</span>
    <span class="pl-s1">request</span> <span class="pl-c1">=</span> <span class="pl-s1">cimgt</span>.<span class="pl-v">OSM</span>()
    <span class="pl-s1">ax1</span><span class="pl-c1">=</span><span class="pl-s1">plt</span>.<span class="pl-en">axes</span>(<span class="pl-s1">projection</span><span class="pl-c1">=</span><span class="pl-s1">request</span>.<span class="pl-s1">crs</span>)
    <span class="pl-s1">ax1</span>.<span class="pl-en">set_extent</span>([<span class="pl-c1">3.25</span>, <span class="pl-c1">7.35</span>, <span class="pl-c1">50.45</span>, <span class="pl-c1">53.55</span>],<span class="pl-s1">ccrs</span>.<span class="pl-v">PlateCarree</span>())
    <span class="pl-s1">ax1</span>.<span class="pl-en">add_image</span>(<span class="pl-s1">request</span>, <span class="pl-c1">10</span>)
    
    <span class="pl-c">#create a rectangular grid a little smaller than the map</span>
    <span class="pl-c">#with cell sizes of 0.01 degree filled with random values</span>
    <span class="pl-s1">nx</span><span class="pl-c1">=</span><span class="pl-c1">400</span>
    <span class="pl-s1">ny</span><span class="pl-c1">=</span><span class="pl-c1">300</span>
    <span class="pl-s1">xedges</span><span class="pl-c1">=</span><span class="pl-s1">np</span>.<span class="pl-en">linspace</span>(<span class="pl-c1">3.3</span>, <span class="pl-c1">7.3</span>, <span class="pl-s1">nx</span>)
    <span class="pl-s1">yedges</span><span class="pl-c1">=</span><span class="pl-s1">np</span>.<span class="pl-en">linspace</span>(<span class="pl-c1">50.5</span>, <span class="pl-c1">53.5</span>, <span class="pl-s1">ny</span>)
    <span class="pl-s1">zvalues</span><span class="pl-c1">=</span><span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">random</span>((<span class="pl-s1">nx</span>, <span class="pl-s1">ny</span>))
    
    <span class="pl-s1">ax1</span>.<span class="pl-en">pcolormesh</span>(<span class="pl-s1">xedges</span>, <span class="pl-s1">yedges</span>, <span class="pl-s1">zvalues</span>.<span class="pl-v">T</span> ,\
                   <span class="pl-s1">alpha</span><span class="pl-c1">=</span><span class="pl-c1">0.3</span>, <span class="pl-s1">shading</span><span class="pl-c1">=</span><span class="pl-s">'auto'</span>, <span class="pl-s1">transform</span><span class="pl-c1">=</span><span class="pl-s1">ccrs</span>.<span class="pl-v">PlateCarree</span>())
        
    <span class="pl-s1">plt</span>.<span class="pl-en">show</span>()</pre></div>
<h3 dir="auto">Actual outcome</h3>
<p dir="auto">Program hangs. Toolbar doesn't response. Hourglass is visible. No errors.<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/72066686/145592426-773429fd-c256-411d-bc67-edf683996b06.png"><img src="https://user-images.githubusercontent.com/72066686/145592426-773429fd-c256-411d-bc67-edf683996b06.png" alt="image" style="max-width: 100%;"></a></p>
<h3 dir="auto">Expected outcome</h3>
<p dir="auto">Plot has been made. Toolbar works, normal running program.<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/72066686/145591331-014c04db-f9f3-4dc7-8808-64e213218fe8.png"><img src="https://user-images.githubusercontent.com/72066686/145591331-014c04db-f9f3-4dc7-8808-64e213218fe8.png" alt="image" style="max-width: 100%;"></a></p>
<h3 dir="auto">Additional information</h3>
<p dir="auto">It worked fine with matplotlib 3.3.3. I can then increase nx,ny to 8000,6000.(I didn't try higher values)<br>
It seems that there is a  'problem' with pcolormesh().<br>
It works fine in mpl 3.5.0 with reduced nx,ny values(i.e. 100,75)</p>
<h3 dir="auto">Operating system</h3>
<p dir="auto">Windows 10</p>
<h3 dir="auto">Matplotlib Version</h3>
<p dir="auto">3.3.3 and 3.5.0</p>
<h3 dir="auto">Matplotlib Backend</h3>
<p dir="auto">Qt5Agg</p>
<h3 dir="auto">Python version</h3>
<p dir="auto">Python 3.8.12</p>
<h3 dir="auto">Jupyter version</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Installation</h3>
<p dir="auto">conda</p>