Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Labels
Milestone
Description
Bug summary
My aim is to plot a colormap with e.g. 5 discrete colors (with 5 ticks centered per color).
Undermatplotlib
3.4.3, I got this working with the code snippet below usingNoNorm
; 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
importmatplotlib.pyplotaspltfrommatplotlibimportcm,colorsdata= [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
Thisis the output undermatplotlib
3.5.0.
Expected outcome
Thiswas the output undermatplotlib
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