Skip to content

aspect="auto" for px.imshow does nothing when plotting RGB data #5172

Open

Description

@martinsondergaard

I am trying to plot an RGB image that strecthes to fill the figure, and I cannot get it to work.

Using a standard 2D array works as expected, and the image is able to dynamically stretch to the figure.

arr = np.random.random((100, 100))
px.imshow(arr, aspect="auto")

But if I instead try to plot an RGB image with the same settings, then the image stays with its original aspect ratio.

img = np.random.random((100, 100, 3))
px.imshow(img, aspect="auto")

In this case, setting the aspect key does nothing and the image keeps a fixed aspect ratio. Explicitly adding with and height also does nothing to change the aspect ratio.

Is this an expected limitation of the aspect setting? If yes, then it should probably be documented.

Activity

  1. 5xx7xx commented on Sep 27, 2025

    @5xx7xx

    Any update on this? I'm running into the same issue. Trying to override it with any layout update to the figure such as scaleanchor=None or height/width setting doesn't work. There also doesn't seem to be a way to make auto aspect non-square pixels RGB image with go.Image, right? And no way to pass direct RGB data to a Heatmap, which allows those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlogbugsomething brokendocumentationwritten for humans

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions