<h3 dir="auto">Bug report</h3>
<p dir="auto"><strong>Bug summary</strong></p>

<p dir="auto">When using a colormap to generate a color array with data that contains np.nan (NaN), an warning is given, and the previous color entry is duplicated.  The method that has this issue is <code class="notranslate">to_rgba</code>.</p>
<p dir="auto"><strong>Code for reproduction</strong></p>

<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import numpy as np
from matplotlib.colors import Normalize
from matplotlib import cm

y = np.linspace(0.0, 1.0, 4)
y[1] = np.nan

norm = Normalize(0.0, 1.0)
colormap = cm.ScalarMappable(norm, 'rainbow')
colors = colormap.to_rgba(y)

print(colors)"><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">from</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">colors</span> <span class="pl-k">import</span> <span class="pl-v">Normalize</span>
<span class="pl-k">from</span> <span class="pl-s1">matplotlib</span> <span class="pl-k">import</span> <span class="pl-s1">cm</span>

<span class="pl-s1">y</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">linspace</span>(<span class="pl-c1">0.0</span>, <span class="pl-c1">1.0</span>, <span class="pl-c1">4</span>)
<span class="pl-s1">y</span>[<span class="pl-c1">1</span>] <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-s1">nan</span>

<span class="pl-s1">norm</span> <span class="pl-c1">=</span> <span class="pl-v">Normalize</span>(<span class="pl-c1">0.0</span>, <span class="pl-c1">1.0</span>)
<span class="pl-s1">colormap</span> <span class="pl-c1">=</span> <span class="pl-s1">cm</span>.<span class="pl-v">ScalarMappable</span>(<span class="pl-s1">norm</span>, <span class="pl-s">'rainbow'</span>)
<span class="pl-s1">colors</span> <span class="pl-c1">=</span> <span class="pl-s1">colormap</span>.<span class="pl-en">to_rgba</span>(<span class="pl-s1">y</span>)

<span class="pl-en">print</span>(<span class="pl-s1">colors</span>)</pre></div>
<p dir="auto"><strong>Actual outcome</strong></p>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/colors.py:496: RuntimeWarning: invalid value encountered in less
  cbook._putmask(xa, xa &lt; 0.0, -1)

[[  5.00000000e-01   0.00000000e+00   1.00000000e+00   1.00000000e+00]
 [  5.00000000e-01   0.00000000e+00   1.00000000e+00   1.00000000e+00]
 [  8.33333333e-01   8.66025404e-01   5.00000000e-01   1.00000000e+00]
 [  1.00000000e+00   1.22464680e-16   6.12323400e-17   1.00000000e+00]]"><pre class="notranslate"><code class="notranslate">/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/colors.py:496: RuntimeWarning: invalid value encountered in less
  cbook._putmask(xa, xa &lt; 0.0, -1)

[[  5.00000000e-01   0.00000000e+00   1.00000000e+00   1.00000000e+00]
 [  5.00000000e-01   0.00000000e+00   1.00000000e+00   1.00000000e+00]
 [  8.33333333e-01   8.66025404e-01   5.00000000e-01   1.00000000e+00]
 [  1.00000000e+00   1.22464680e-16   6.12323400e-17   1.00000000e+00]]
</code></pre></div>
<p dir="auto"><strong>Expected outcome</strong></p>
<p dir="auto">NaN values should be quietly handled.  I think the most reasonable output would be to fill the color array with np.nan rather than copy the previous entry.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[[  5.00000000e-01   0.00000000e+00   1.00000000e+00   1.00000000e+00]
 [  NaN              NaN              NaN              NaN]
 [  8.33333333e-01   8.66025404e-01   5.00000000e-01   1.00000000e+00]
 [  1.00000000e+00   1.22464680e-16   6.12323400e-17   1.00000000e+00]]"><pre class="notranslate"><code class="notranslate">[[  5.00000000e-01   0.00000000e+00   1.00000000e+00   1.00000000e+00]
 [  NaN              NaN              NaN              NaN]
 [  8.33333333e-01   8.66025404e-01   5.00000000e-01   1.00000000e+00]
 [  1.00000000e+00   1.22464680e-16   6.12323400e-17   1.00000000e+00]]
</code></pre></div>


<p dir="auto"><strong>Matplotlib version</strong></p>

<ul dir="auto">
<li>Operating system: OSX</li>
<li>Matplotlib version: 2.0.2</li>
<li>Matplotlib backend: module://ipykernel.pylab.backend_inline &amp; MacOSX</li>
<li>Python version: 3.6.3</li>
<li>Jupyter Notebook version: 5.2.0</li>
<li>Other libraries: None</li>
</ul>
<h3 dir="auto">Bug summary</h3>
<p dir="auto">The default minor colorbar ticks in matplotlib 3.5.1 look strange in the presence of major ticks determined by <code class="notranslate">BoundaryNorm</code>. Thought I had seen this issue in a previous thread but can't seem to find it... apologies if this is a duplicate.</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 matplotlib
import numpy as np
import matplotlib.pyplot as plt

crf_bounds = np.array([0, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 0.97, 0.98, 0.99, 1.0])
norm = matplotlib.colors.BoundaryNorm(boundaries=crf_bounds, ncolors=256)

x = y = np.array([-10, -5, 0, 5, 10])
np.random.seed(20)
data = np.random.uniform(0,1,(4,4))

fig = plt.figure()
ax = fig.add_subplot()
m = ax.pcolormesh(x, y, data, cmap='RdYlGn', norm=norm)
cb = fig.colorbar(m)
cb.minorticks_on()"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">matplotlib</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-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>

<span class="pl-s1">crf_bounds</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-c1">0</span>, <span class="pl-c1">0.7</span>, <span class="pl-c1">0.75</span>, <span class="pl-c1">0.8</span>, <span class="pl-c1">0.85</span>, <span class="pl-c1">0.9</span>, <span class="pl-c1">0.95</span>, <span class="pl-c1">0.97</span>, <span class="pl-c1">0.98</span>, <span class="pl-c1">0.99</span>, <span class="pl-c1">1.0</span>])
<span class="pl-s1">norm</span> <span class="pl-c1">=</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">colors</span>.<span class="pl-v">BoundaryNorm</span>(<span class="pl-s1">boundaries</span><span class="pl-c1">=</span><span class="pl-s1">crf_bounds</span>, <span class="pl-s1">ncolors</span><span class="pl-c1">=</span><span class="pl-c1">256</span>)

<span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">y</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-c1">-</span><span class="pl-c1">10</span>, <span class="pl-c1">-</span><span class="pl-c1">5</span>, <span class="pl-c1">0</span>, <span class="pl-c1">5</span>, <span class="pl-c1">10</span>])
<span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">seed</span>(<span class="pl-c1">20</span>)
<span class="pl-s1">data</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">uniform</span>(<span class="pl-c1">0</span>,<span class="pl-c1">1</span>,(<span class="pl-c1">4</span>,<span class="pl-c1">4</span>))

<span class="pl-s1">fig</span> <span class="pl-c1">=</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">fig</span>.<span class="pl-en">add_subplot</span>()
<span class="pl-s1">m</span> <span class="pl-c1">=</span> <span class="pl-s1">ax</span>.<span class="pl-en">pcolormesh</span>(<span class="pl-s1">x</span>, <span class="pl-s1">y</span>, <span class="pl-s1">data</span>, <span class="pl-s1">cmap</span><span class="pl-c1">=</span><span class="pl-s">'RdYlGn'</span>, <span class="pl-s1">norm</span><span class="pl-c1">=</span><span class="pl-s1">norm</span>)
<span class="pl-s1">cb</span> <span class="pl-c1">=</span> <span class="pl-s1">fig</span>.<span class="pl-en">colorbar</span>(<span class="pl-s1">m</span>)
<span class="pl-s1">cb</span>.<span class="pl-en">minorticks_on</span>()</pre></div>
<h3 dir="auto">Actual outcome</h3>
<p dir="auto">Matplotlib 3.5.1 result:</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/19657652/149579945-9482bda0-846e-4d77-99a3-417af76df29e.png"><img src="https://user-images.githubusercontent.com/19657652/149579945-9482bda0-846e-4d77-99a3-417af76df29e.png" alt="tmp" style="max-width: 100%;"></a></p>
<h3 dir="auto">Expected outcome</h3>
<p dir="auto">Matplotlib 3.2.1 result:</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/19657652/149580206-c030ce00-8fcf-43e7-b70e-d2c392f4012d.png"><img src="https://user-images.githubusercontent.com/19657652/149580206-c030ce00-8fcf-43e7-b70e-d2c392f4012d.png" alt="tmp_nice" style="max-width: 100%;"></a></p>
<h3 dir="auto">Additional information</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Operating system</h3>
<p dir="auto">MacOS</p>
<h3 dir="auto">Matplotlib Version</h3>
<p dir="auto">3.5.1</p>
<h3 dir="auto">Matplotlib Backend</h3>
<p dir="auto">module://matplotlib_inline.backend_inline</p>
<h3 dir="auto">Python version</h3>
<p dir="auto">3.9.9</p>
<h3 dir="auto">Jupyter version</h3>
<p dir="auto">3.1.18</p>
<h3 dir="auto">Installation</h3>
<p dir="auto">conda</p>