Skip to content

[Bug]: Setting alpha with an array is ignored with jupyterlab %inline backend #29595

Closed
@rhiannonlynne

Description

@rhiannonlynne

Bug summary

If alpha is set as an array (of equal shape as the image data), the alpha value is ignored.
This is failing for inline plots in Jupyter Lab.

Code for reproduction

import matplotlib
print(matplotlib.__version__)

import numpy as np
import matplotlib.pyplot as plt

img_data = np.random.rand(256, 200)
alpha = np.ones((256, 200))
alpha[:, 0:100] = 0.5
fig, ax = plt.subplots(1, 2, figsize=(10, 8))
ax[0].imshow(img_data, alpha=alpha)
ax[1].imshow(alpha)

Actual outcome

Image

Expected outcome

Image

Additional information

Worked with Matplotlib 3.9.4 with numpy 2.2.1
Fails in matplotlib 3.10.0 (same numpy), running in a Jupyter Lab cell.
Worked as expected when run from the command line, with backend 'macosx', or if %matplotlib osx or %matplotlib ipympl is used to decorate the cell before running the code above.

Operating system

OS/X

Matplotlib Version

3.10.0

Matplotlib Backend

inline

Python version

3.13.1

Jupyter version

4.3.4

Installation

conda

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions