Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Bug]: Colormap + NoNorm only plots one color undermatplotlib 3.5.0 #21870

Closed
@dominiquesydow

Description

@dominiquesydow

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

image

Thisis the output undermatplotlib 3.5.0.

Expected outcome

image

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp