Skip to content

Allow colormap scaling to reflect raw counts instead of hard-coded [0, 1] range #387

Open

Description

@lijinbio

Hi there,

Currently, when visualizing gene expression or numerical observations in napari-spatialdata, the colormap and colorbar appear to be hard-coded to a range of $[0, 1]$. This is specifically seen in src/napari_spatialdata/_widgets.py (around line 488), where the data is normalized before being passed to the visualization layer.While normalization is useful for consistent styling, it makes it impossible for users to see the actual raw counts of a gene on the colorbar or via the contrast limits slider. For example, if a gene's expression ranges from 0 to 50, the colorbar still displays 0 to 1, and the user has no visual confirmation of the true expression magnitude.

I would like an option (or a change in default behavior) where:

  1. The colormap scale and contrast limits are automatically set to (min, max) of the raw counts for the selected gene/variable.
  2. The colorbar widget reflects these true values instead of the normalized $[0, 1]$ range.
  3. Users can manually adjust these limits in the napari layer controls to values outside the $[0, 1]$ range if needed.

Activity

  1. LucaMarconato commented on Mar 1, 2026

    @LucaMarconato
    Member

    Hi, thanks for reporting. It's a bit hidden napari UI feature, but if you right click on the contrast limit slider you will be able to change limits. Did you try that?

    Regarding an automatic limit based on min, max, it may slow down the interface for large non-raster, non-pyramidal data, so that would have to be considered carefully.

  2. lijinbio commented on Apr 7, 2026

    @lijinbio
    Author

    Hi @LucaMarconato , thank you for your suggestions. I just wanted to let you know that after following them, the right-click option does not show the limits to change.

  3. AlbertoFabbri93 commented on Apr 27, 2026

    @AlbertoFabbri93
    Image

    Is the contrast limit slider the one in the picture or? Because nothing happens when I change the range.

  4. LucaMarconato commented on May 11, 2026

    @LucaMarconato
    Member

    @lijinbio now I understood. I was referring to the "contrast limits" slider (for raster data), this one here:

    Image

    @lijinbio @AlbertoFabbri93 the colorbar slider is not working, it's a known issue, it will be addressed in a future version #227

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions