<h3 dir="auto">Bug report</h3>
<p dir="auto"><strong>Bug summary</strong></p>
<p dir="auto">When trying to pass a pandas.Sequence to matplotlib.colors.LogNorm to set the norm of a LineCollection I expect it to handle it similar to matplotlib.colors.Normalize. However the LineCollection is not properly set.</p>
<p dir="auto">This might also be an issue with using LineCollection.set_array() but in any case I would expect both Normalize and LogNorm to handle this similarly.</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
import pandas as pd
from matplotlib.colors import LogNorm, Normalize
from matplotlib.collections import LineCollection
import matplotlib.pyplot as plt
x=np.arange(1, 11)
y=np.arange(1, 11)
z=pd.Series(np.logspace(-5.0, 9, num=10))

points = np.array([x, y]).T.reshape(-1, 1, 2)
segments = np.concatenate([points[:-1], points[1:]], axis=1)

norms = [plt.Normalize(vmin=z.min(), vmax=z.max()),
         LogNorm(vmin=z.min(), vmax=z.max()),
         Normalize(vmin=z.min(), vmax=z.max())]

# the different cases I tried: 
for norm in norms:
    print(f&quot;Trying: {type(norm)}&quot;)
    fig, ax = plt.subplots(constrained_layout=True)
    try:
        lc = LineCollection(segments, cmap='viridis', norm=norm)
        
        lc.set_array(z)
        lc.set_linewidth(10)
        line = ax.add_collection(lc)
        fig.colorbar(line, ax=ax)
        
        ax.plot(x, y)
        fig.show()
    except TypeError as e:   
        print(e)
    plt.clf()

# and finally the part that causes the issue: 
norm = LogNorm(vmin=z.min(), vmax=z.max())
fig, ax = plt.subplots(constrained_layout=True)
lc = LineCollection(segments, cmap='viridis', norm=norm)

lc.set_array(z)
lc.set_linewidth(10)
line = ax.add_collection(lc)
fig.colorbar(line, ax=ax)
        
ax.plot(x, y)
fig.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">pandas</span> <span class="pl-k">as</span> <span class="pl-s1">pd</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">LogNorm</span>, <span class="pl-v">Normalize</span>
<span class="pl-k">from</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">collections</span> <span class="pl-k">import</span> <span class="pl-v">LineCollection</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">x</span><span class="pl-c1">=</span><span class="pl-s1">np</span>.<span class="pl-en">arange</span>(<span class="pl-c1">1</span>, <span class="pl-c1">11</span>)
<span class="pl-s1">y</span><span class="pl-c1">=</span><span class="pl-s1">np</span>.<span class="pl-en">arange</span>(<span class="pl-c1">1</span>, <span class="pl-c1">11</span>)
<span class="pl-s1">z</span><span class="pl-c1">=</span><span class="pl-s1">pd</span>.<span class="pl-v">Series</span>(<span class="pl-s1">np</span>.<span class="pl-en">logspace</span>(<span class="pl-c1">-</span><span class="pl-c1">5.0</span>, <span class="pl-c1">9</span>, <span class="pl-s1">num</span><span class="pl-c1">=</span><span class="pl-c1">10</span>))

<span class="pl-s1">points</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-s1">x</span>, <span class="pl-s1">y</span>]).<span class="pl-v">T</span>.<span class="pl-en">reshape</span>(<span class="pl-c1">-</span><span class="pl-c1">1</span>, <span class="pl-c1">1</span>, <span class="pl-c1">2</span>)
<span class="pl-s1">segments</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">concatenate</span>([<span class="pl-s1">points</span>[:<span class="pl-c1">-</span><span class="pl-c1">1</span>], <span class="pl-s1">points</span>[<span class="pl-c1">1</span>:]], <span class="pl-s1">axis</span><span class="pl-c1">=</span><span class="pl-c1">1</span>)

<span class="pl-s1">norms</span> <span class="pl-c1">=</span> [<span class="pl-s1">plt</span>.<span class="pl-v">Normalize</span>(<span class="pl-s1">vmin</span><span class="pl-c1">=</span><span class="pl-s1">z</span>.<span class="pl-en">min</span>(), <span class="pl-s1">vmax</span><span class="pl-c1">=</span><span class="pl-s1">z</span>.<span class="pl-en">max</span>()),
         <span class="pl-v">LogNorm</span>(<span class="pl-s1">vmin</span><span class="pl-c1">=</span><span class="pl-s1">z</span>.<span class="pl-en">min</span>(), <span class="pl-s1">vmax</span><span class="pl-c1">=</span><span class="pl-s1">z</span>.<span class="pl-en">max</span>()),
         <span class="pl-v">Normalize</span>(<span class="pl-s1">vmin</span><span class="pl-c1">=</span><span class="pl-s1">z</span>.<span class="pl-en">min</span>(), <span class="pl-s1">vmax</span><span class="pl-c1">=</span><span class="pl-s1">z</span>.<span class="pl-en">max</span>())]

<span class="pl-c"># the different cases I tried: </span>
<span class="pl-k">for</span> <span class="pl-s1">norm</span> <span class="pl-c1">in</span> <span class="pl-s1">norms</span>:
    <span class="pl-en">print</span>(<span class="pl-s">f"Trying: <span class="pl-s1"><span class="pl-kos">{</span><span class="pl-en">type</span>(<span class="pl-s1">norm</span>)<span class="pl-kos">}</span></span>"</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">constrained_layout</span><span class="pl-c1">=</span><span class="pl-c1">True</span>)
    <span class="pl-k">try</span>:
        <span class="pl-s1">lc</span> <span class="pl-c1">=</span> <span class="pl-v">LineCollection</span>(<span class="pl-s1">segments</span>, <span class="pl-s1">cmap</span><span class="pl-c1">=</span><span class="pl-s">'viridis'</span>, <span class="pl-s1">norm</span><span class="pl-c1">=</span><span class="pl-s1">norm</span>)
        
        <span class="pl-s1">lc</span>.<span class="pl-en">set_array</span>(<span class="pl-s1">z</span>)
        <span class="pl-s1">lc</span>.<span class="pl-en">set_linewidth</span>(<span class="pl-c1">10</span>)
        <span class="pl-s1">line</span> <span class="pl-c1">=</span> <span class="pl-s1">ax</span>.<span class="pl-en">add_collection</span>(<span class="pl-s1">lc</span>)
        <span class="pl-s1">fig</span>.<span class="pl-en">colorbar</span>(<span class="pl-s1">line</span>, <span class="pl-s1">ax</span><span class="pl-c1">=</span><span class="pl-s1">ax</span>)
        
        <span class="pl-s1">ax</span>.<span class="pl-en">plot</span>(<span class="pl-s1">x</span>, <span class="pl-s1">y</span>)
        <span class="pl-s1">fig</span>.<span class="pl-en">show</span>()
    <span class="pl-k">except</span> <span class="pl-v">TypeError</span> <span class="pl-k">as</span> <span class="pl-s1">e</span>:   
        <span class="pl-en">print</span>(<span class="pl-s1">e</span>)
    <span class="pl-s1">plt</span>.<span class="pl-en">clf</span>()

<span class="pl-c"># and finally the part that causes the issue: </span>
<span class="pl-s1">norm</span> <span class="pl-c1">=</span> <span class="pl-v">LogNorm</span>(<span class="pl-s1">vmin</span><span class="pl-c1">=</span><span class="pl-s1">z</span>.<span class="pl-en">min</span>(), <span class="pl-s1">vmax</span><span class="pl-c1">=</span><span class="pl-s1">z</span>.<span class="pl-en">max</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">constrained_layout</span><span class="pl-c1">=</span><span class="pl-c1">True</span>)
<span class="pl-s1">lc</span> <span class="pl-c1">=</span> <span class="pl-v">LineCollection</span>(<span class="pl-s1">segments</span>, <span class="pl-s1">cmap</span><span class="pl-c1">=</span><span class="pl-s">'viridis'</span>, <span class="pl-s1">norm</span><span class="pl-c1">=</span><span class="pl-s1">norm</span>)

<span class="pl-s1">lc</span>.<span class="pl-en">set_array</span>(<span class="pl-s1">z</span>)
<span class="pl-s1">lc</span>.<span class="pl-en">set_linewidth</span>(<span class="pl-c1">10</span>)
<span class="pl-s1">line</span> <span class="pl-c1">=</span> <span class="pl-s1">ax</span>.<span class="pl-en">add_collection</span>(<span class="pl-s1">lc</span>)
<span class="pl-s1">fig</span>.<span class="pl-en">colorbar</span>(<span class="pl-s1">line</span>, <span class="pl-s1">ax</span><span class="pl-c1">=</span><span class="pl-s1">ax</span>)
        
<span class="pl-s1">ax</span>.<span class="pl-en">plot</span>(<span class="pl-s1">x</span>, <span class="pl-s1">y</span>)
<span class="pl-s1">fig</span>.<span class="pl-en">show</span>()</pre></div>
<p dir="auto"><strong>Actual outcome</strong></p>
<p dir="auto">see the error being raised above</p>
<p dir="auto"><strong>Expected outcome</strong><br>
Using a np.array instead of a pd.Sequence</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import numpy as np
import pandas as pd
from matplotlib.colors import LogNorm, Normalize
from matplotlib.collections import LineCollection
import matplotlib.pyplot as plt
x=np.arange(1, 11)
y=np.arange(1, 11)
### now z is set as an np.array
z=np.logspace(-5.0, 9, num=10)

points = np.array([x, y]).T.reshape(-1, 1, 2)
segments = np.concatenate([points[:-1], points[1:]], axis=1)

norm = LogNorm(vmin=z.min(), vmax=z.max())

fig, ax = plt.subplots(constrained_layout=True)
lc = LineCollection(segments, cmap='viridis', norm=norm)

lc.set_array(z)
lc.set_linewidth(10)
line = ax.add_collection(lc)
fig.colorbar(line, ax=ax)
        
ax.plot(x, y)
fig.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">pandas</span> <span class="pl-k">as</span> <span class="pl-s1">pd</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">LogNorm</span>, <span class="pl-v">Normalize</span>
<span class="pl-k">from</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">collections</span> <span class="pl-k">import</span> <span class="pl-v">LineCollection</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">x</span><span class="pl-c1">=</span><span class="pl-s1">np</span>.<span class="pl-en">arange</span>(<span class="pl-c1">1</span>, <span class="pl-c1">11</span>)
<span class="pl-s1">y</span><span class="pl-c1">=</span><span class="pl-s1">np</span>.<span class="pl-en">arange</span>(<span class="pl-c1">1</span>, <span class="pl-c1">11</span>)
<span class="pl-c">### now z is set as an np.array</span>
<span class="pl-s1">z</span><span class="pl-c1">=</span><span class="pl-s1">np</span>.<span class="pl-en">logspace</span>(<span class="pl-c1">-</span><span class="pl-c1">5.0</span>, <span class="pl-c1">9</span>, <span class="pl-s1">num</span><span class="pl-c1">=</span><span class="pl-c1">10</span>)

<span class="pl-s1">points</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-s1">x</span>, <span class="pl-s1">y</span>]).<span class="pl-v">T</span>.<span class="pl-en">reshape</span>(<span class="pl-c1">-</span><span class="pl-c1">1</span>, <span class="pl-c1">1</span>, <span class="pl-c1">2</span>)
<span class="pl-s1">segments</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">concatenate</span>([<span class="pl-s1">points</span>[:<span class="pl-c1">-</span><span class="pl-c1">1</span>], <span class="pl-s1">points</span>[<span class="pl-c1">1</span>:]], <span class="pl-s1">axis</span><span class="pl-c1">=</span><span class="pl-c1">1</span>)

<span class="pl-s1">norm</span> <span class="pl-c1">=</span> <span class="pl-v">LogNorm</span>(<span class="pl-s1">vmin</span><span class="pl-c1">=</span><span class="pl-s1">z</span>.<span class="pl-en">min</span>(), <span class="pl-s1">vmax</span><span class="pl-c1">=</span><span class="pl-s1">z</span>.<span class="pl-en">max</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">constrained_layout</span><span class="pl-c1">=</span><span class="pl-c1">True</span>)
<span class="pl-s1">lc</span> <span class="pl-c1">=</span> <span class="pl-v">LineCollection</span>(<span class="pl-s1">segments</span>, <span class="pl-s1">cmap</span><span class="pl-c1">=</span><span class="pl-s">'viridis'</span>, <span class="pl-s1">norm</span><span class="pl-c1">=</span><span class="pl-s1">norm</span>)

<span class="pl-s1">lc</span>.<span class="pl-en">set_array</span>(<span class="pl-s1">z</span>)
<span class="pl-s1">lc</span>.<span class="pl-en">set_linewidth</span>(<span class="pl-c1">10</span>)
<span class="pl-s1">line</span> <span class="pl-c1">=</span> <span class="pl-s1">ax</span>.<span class="pl-en">add_collection</span>(<span class="pl-s1">lc</span>)
<span class="pl-s1">fig</span>.<span class="pl-en">colorbar</span>(<span class="pl-s1">line</span>, <span class="pl-s1">ax</span><span class="pl-c1">=</span><span class="pl-s1">ax</span>)
        
<span class="pl-s1">ax</span>.<span class="pl-en">plot</span>(<span class="pl-s1">x</span>, <span class="pl-s1">y</span>)
<span class="pl-s1">fig</span>.<span class="pl-en">show</span>()</pre></div>
<p dir="auto"><strong>Matplotlib version</strong></p>
<ul dir="auto">
<li>Operating system:  Win 10</li>
<li>Matplotlib version: 3.4.1</li>
<li>Matplotlib backend: module://backend_interagg</li>
<li>Python version: 3.8</li>
<li>Other libraries: pandas</li>
</ul>
<h3 dir="auto">Bug report</h3>
<p dir="auto"><strong>Bug summary</strong><br>
It seems matplotlib.colors.Normalize can work with pandas.Series inputs, whereas LogNorm can't.</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
import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection
from matplotlib.colors import ListedColormap, BoundaryNorm, Normalize, LogNorm
import pandas as pd

x = np.linspace(0, 3 * np.pi, 500)
y = np.sin(x)
dydx = np.linspace(0, 3 * np.pi, 500) +1  # first derivative
df= pd.DataFrame({'x':x,'y':y,'dydx':dydx})
points = np.array([df['x'], df['y']]).T.reshape(-1, 1, 2)
segments = np.concatenate([points[:-1], points[1:]], axis=1)
fig, axs = plt.subplots()

# Create a continuous norm to map from data points to colors
norm = LogNorm(df['dydx'].min(), df['dydx'].max())
lc = LineCollection(segments, cmap='viridis', norm=norm)
# Set the values used for colormapping
lc.set_array(df['dydx'])
lc.set_linewidth(2)
line = axs.add_collection(lc)
fig.colorbar(line, ax=axs)
axs.set_xlim(x.min(), x.max())
axs.set_ylim(-1.1, 1.1)
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">from</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">collections</span> <span class="pl-k">import</span> <span class="pl-v">LineCollection</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">ListedColormap</span>, <span class="pl-v">BoundaryNorm</span>, <span class="pl-v">Normalize</span>, <span class="pl-v">LogNorm</span>
<span class="pl-k">import</span> <span class="pl-s1">pandas</span> <span class="pl-k">as</span> <span class="pl-s1">pd</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">0</span>, <span class="pl-c1">3</span> <span class="pl-c1">*</span> <span class="pl-s1">np</span>.<span class="pl-s1">pi</span>, <span class="pl-c1">500</span>)
<span class="pl-s1">y</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">sin</span>(<span class="pl-s1">x</span>)
<span class="pl-s1">dydx</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">linspace</span>(<span class="pl-c1">0</span>, <span class="pl-c1">3</span> <span class="pl-c1">*</span> <span class="pl-s1">np</span>.<span class="pl-s1">pi</span>, <span class="pl-c1">500</span>) <span class="pl-c1">+</span><span class="pl-c1">1</span>  <span class="pl-c"># first derivative</span>
<span class="pl-s1">df</span><span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>({<span class="pl-s">'x'</span>:<span class="pl-s1">x</span>,<span class="pl-s">'y'</span>:<span class="pl-s1">y</span>,<span class="pl-s">'dydx'</span>:<span class="pl-s1">dydx</span>})
<span class="pl-s1">points</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-s1">df</span>[<span class="pl-s">'x'</span>], <span class="pl-s1">df</span>[<span class="pl-s">'y'</span>]]).<span class="pl-v">T</span>.<span class="pl-en">reshape</span>(<span class="pl-c1">-</span><span class="pl-c1">1</span>, <span class="pl-c1">1</span>, <span class="pl-c1">2</span>)
<span class="pl-s1">segments</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">concatenate</span>([<span class="pl-s1">points</span>[:<span class="pl-c1">-</span><span class="pl-c1">1</span>], <span class="pl-s1">points</span>[<span class="pl-c1">1</span>:]], <span class="pl-s1">axis</span><span class="pl-c1">=</span><span class="pl-c1">1</span>)
<span class="pl-s1">fig</span>, <span class="pl-s1">axs</span> <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-en">subplots</span>()

<span class="pl-c"># Create a continuous norm to map from data points to colors</span>
<span class="pl-s1">norm</span> <span class="pl-c1">=</span> <span class="pl-v">LogNorm</span>(<span class="pl-s1">df</span>[<span class="pl-s">'dydx'</span>].<span class="pl-en">min</span>(), <span class="pl-s1">df</span>[<span class="pl-s">'dydx'</span>].<span class="pl-en">max</span>())
<span class="pl-s1">lc</span> <span class="pl-c1">=</span> <span class="pl-v">LineCollection</span>(<span class="pl-s1">segments</span>, <span class="pl-s1">cmap</span><span class="pl-c1">=</span><span class="pl-s">'viridis'</span>, <span class="pl-s1">norm</span><span class="pl-c1">=</span><span class="pl-s1">norm</span>)
<span class="pl-c"># Set the values used for colormapping</span>
<span class="pl-s1">lc</span>.<span class="pl-en">set_array</span>(<span class="pl-s1">df</span>[<span class="pl-s">'dydx'</span>])
<span class="pl-s1">lc</span>.<span class="pl-en">set_linewidth</span>(<span class="pl-c1">2</span>)
<span class="pl-s1">line</span> <span class="pl-c1">=</span> <span class="pl-s1">axs</span>.<span class="pl-en">add_collection</span>(<span class="pl-s1">lc</span>)
<span class="pl-s1">fig</span>.<span class="pl-en">colorbar</span>(<span class="pl-s1">line</span>, <span class="pl-s1">ax</span><span class="pl-c1">=</span><span class="pl-s1">axs</span>)
<span class="pl-s1">axs</span>.<span class="pl-en">set_xlim</span>(<span class="pl-s1">x</span>.<span class="pl-en">min</span>(), <span class="pl-s1">x</span>.<span class="pl-en">max</span>())
<span class="pl-s1">axs</span>.<span class="pl-en">set_ylim</span>(<span class="pl-c1">-</span><span class="pl-c1">1.1</span>, <span class="pl-c1">1.1</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">show</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="TypeError: '&lt;=' not supported between instances of 'SingleBlockManager' and 'int'"><pre class="notranslate"><code class="notranslate">TypeError: '&lt;=' not supported between instances of 'SingleBlockManager' and 'int'
</code></pre></div>
<p dir="auto"><strong>Expected outcome</strong></p>
<p dir="auto">Not sure about what's expected, but if I do <code class="notranslate">Normalize</code> instead of <code class="notranslate">LogNorm</code> it works, if I do <code class="notranslate">lc.set_array(df['dydx'].to_numpy())</code>  instead of <code class="notranslate">lc.set_array(df['dydx'])</code> it also works. It's the combination of LogNorm and pd.Series is the problem.</p>


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

<p dir="auto">version 3.1.1<br>
module://ipykernel.pylab.backend_inline</p>