Skip to content

BUG: cannot set colorbar norm to SymLogNorm with base !=10 #4448

@neutrinoceros

Description

@neutrinoceros

Bug report

Bug summary

Since yt 4.1.0, setting arbitrary colorbar norms is supported, however internally, isinstance(norm, SymLogNorm) is used with no regards to the actual base (base 10 is implicitly assumed) to trigger some hard coded special behaviours (most importantly setting minor ticks, which isn't handled well by matplotlib for this norm type).

Code for reproduction

import yt
from matplotlib.colors import SymLogNorm

yt.set_log_level("warning")

ds = yt.load_sample("IsolatedGalaxy")
p = yt.SlicePlot(ds, "z", ("gas", "velocity_x"))
p.set_norm(("gas", "velocity_x"), SymLogNorm(linthresh=1, base=2))
p.save("/tmp/test_sym.png")

Actual outcome

yt : [WARNING  ] 2023-05-21 14:59:45,100 Dropping norm constraints (norm_type=<class 'matplotlib.colors.Normalize'>)

test_sym

Expected outcome

Ticks should be powers of 2 instead of powers of 10.

Version Information

  • Operating System: MacOS
  • Python Version: 3.11.1
  • yt version: 4.1.x
  • Other Libraries (if applicable): matplotlib 3.7.1

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