<h3 dir="auto">Bug summary</h3>
<p dir="auto">Hello, I have tried to run this code I have found on the internet : <a href="https://your-article-is-too-long.tumblr.com/post/625544391640203264/how-does-fire-spread" rel="nofollow">https://your-article-is-too-long.tumblr.com/post/625544391640203264/how-does-fire-spread</a><br>
I have these errors. What has gone wrong ?<br>
Many thanks</p>
<h3 dir="auto">Bug summary</h3>
<p dir="auto">In 3.5.0 if you do:</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
import matplotlib as mpl

fig, ax = plt.subplots()
norm = mpl.colors.BoundaryNorm(np.linspace(-4, 4, 5), 256)
X = np.random.randn(10, 10)
pc = ax.imshow(X, cmap='RdBu_r', norm=norm)"><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-k">import</span> <span class="pl-s1">matplotlib</span> <span class="pl-k">as</span> <span class="pl-s1">mpl</span>

<span class="pl-s1">fig</span>, <span class="pl-s1">ax</span> <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-en">subplots</span>()
<span class="pl-s1">norm</span> <span class="pl-c1">=</span> <span class="pl-s1">mpl</span>.<span class="pl-s1">colors</span>.<span class="pl-v">BoundaryNorm</span>(<span class="pl-s1">np</span>.<span class="pl-en">linspace</span>(<span class="pl-c1">-</span><span class="pl-c1">4</span>, <span class="pl-c1">4</span>, <span class="pl-c1">5</span>), <span class="pl-c1">256</span>)
<span class="pl-v">X</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">randn</span>(<span class="pl-c1">10</span>, <span class="pl-c1">10</span>)
<span class="pl-s1">pc</span> <span class="pl-c1">=</span> <span class="pl-s1">ax</span>.<span class="pl-en">imshow</span>(<span class="pl-v">X</span>, <span class="pl-s1">cmap</span><span class="pl-c1">=</span><span class="pl-s">'RdBu_r'</span>, <span class="pl-s1">norm</span><span class="pl-c1">=</span><span class="pl-s1">norm</span>)</pre></div>
<p dir="auto">and mouse over the image, it crashes with</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="File &quot;/Users/jklymak/matplotlib/lib/matplotlib/artist.py&quot;, line 1282, in format_cursor_data
    neighbors = self.norm.inverse(
  File &quot;/Users/jklymak/matplotlib/lib/matplotlib/colors.py&quot;, line 1829, in inverse
    raise ValueError(&quot;BoundaryNorm is not invertible&quot;)
ValueError: BoundaryNorm is not invertible"><pre class="notranslate"><code class="notranslate">File "/Users/jklymak/matplotlib/lib/matplotlib/artist.py", line 1282, in format_cursor_data
    neighbors = self.norm.inverse(
  File "/Users/jklymak/matplotlib/lib/matplotlib/colors.py", line 1829, in inverse
    raise ValueError("BoundaryNorm is not invertible")
ValueError: BoundaryNorm is not invertible
</code></pre></div>
<p dir="auto">and interaction stops.</p>
<p dir="auto">Not sure if we should have a special check here, a try-except, or actually just make BoundaryNorm approximately invertible.</p>
<h3 dir="auto">Matplotlib Version</h3>
<p dir="auto">main 3.5.0</p>