Skip to content

colors has no field TwoSlopeNorm #581

Open

Description

@xiang-yu

Hi everyone,

It appears that "colors" function imported from matplotlib does not have "Normalize" or "TwoSlopeNorm" field.
Any idea about this?

using PyPlot
vmin, vmax = -1, 1
norm = colors.TwoSlopeNorm(vmin=vmin, vcenter=0., vmax=vmax)

ERROR: type #colors has no field TwoSlopeNorm

Anyways, my goal is to set the colorbar zero at center with symmetric color range.

pcolormesh(data, cmap="RdBu_r", norm = norm, shading="auto")
Colorbar() 

Activity

  1. stevengj commented on Mar 19, 2024

    @stevengj
    Member

    colors in PyPlot is currently a wrapper function, not the underlying Python object. If you want the underlying Python object, you can use matplotlib.colors:

    matplotlib.colors.TwoSlopeNorm(vmin=vmin, vcenter=0., vmax=vmax)
  2. xiang-yu commented on Mar 24, 2024

    @xiang-yu
    Author

    Thanks a lot.

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