Closed
Description
Bug summary
My aim is to plot a colormap with e.g. 5 discrete colors (with 5 ticks centered per color).
Under matplotlib
3.4.3, I got this working with the code snippet below using NoNorm
; under 3.5.0, only one color is plotted.
Is this a bug - or is my setup incorrect/unidiomatic and worked only by chance before?
Code for reproduction
import matplotlib.pyplot as plt
from matplotlib import cm, colors
data = [1, 2, 3, 4, 5]
fig, ax = plt.subplots(figsize=(6, 1))
fig.subplots_adjust(bottom=0.5)
norm = colors.NoNorm(vmin=min(data), vmax=max(data))
cmap = cm.get_cmap("viridis", len(data))
cbar = fig.colorbar(cm.ScalarMappable(norm=norm, cmap=cmap), cax=ax, orientation="horizontal")
print(cbar.get_ticks())
Actual outcome
This is the output under matplotlib
3.5.0.
Expected outcome
This was the output under matplotlib
3.4.3.
Additional information
No response
Operating system
Ubuntu
Matplotlib Version
3.5.0
Matplotlib Backend
module://matplotlib_inline.backend_inline
Python version
Python 3.9.7
Jupyter version
3.2.4
Installation
conda