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]: pcolormesh passes alpha value down to colormap instead of alpha blending #29761

Open
@aw32

Description

@aw32

Bug summary

Using a combination of the following:

  • pcolormesh with a set alpha parameter
  • a colormap that uses the alpha channel for color mapping
    results in the colormap using the alpha parameter from pcolormesh as a constant.

Expected result would be that all resulting values from the colormapping are additionally blended with the alpha parameter from pcolormesh.

Code for reproduction

importmatplotlib.pyplotaspltimportmatplotlib.colorscdict={'red':[(0.0,None,1.0),               (1.0,1.0,None)],'green': [(0.0,None,0.0),               (1.0,0.0,None)],'blue':  [(0.0,None,0.0),               (1.0,0.0,None)],'alpha': [(0.0,None,0.0),               (1.0,1.0,None)]}cmap=matplotlib.colors.LinearSegmentedColormap('custom',cdict,256)H= [[1,2,3]]yedges= [0,1]xedges= [0,1,2,3]f, (ax1,ax2)=plt.subplots(2,1)# case 1: no alpha, colormap defines alpha of valuesax1.pcolormesh(xedges,yedges,H,cmap=cmap)ax1.set_title("pcolormesh without alpha parameter")# case 2: with alpha, alpha is passed to colormap and every value has the same alphaax2.pcolormesh(xedges,yedges,H,cmap=cmap,alpha=0.5)ax2.set_title("pcolormesh with alpha parameter 0.5")plt.show()

Actual outcome

Image

Expected outcome

Image

The expected outcome is, that the "normal" output of pcolormesh isadditionally alpha blended.

Additional information

This happens when an alpha parameter is passed to pcolormesh.
I suspect that the alpha parameter is passed to the colormap call, which effectively sets the colormap result alpha value to a constant.

Operating system

MacOS

Matplotlib Version

3.10.1

Matplotlib Backend

macosx

Python version

Python 3.13.1

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp