Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
neutrinoceros opened this issue May 21, 2023 · 1 comment · Fixed by #4449
Closed

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

neutrinoceros opened this issue May 21, 2023 · 1 comment · Fixed by #4449

Comments

@neutrinoceros
Copy link
Member

neutrinoceros commented May 21, 2023

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
@neutrinoceros
Copy link
Member Author

neutrinoceros commented May 21, 2023

I find that while this is definitely fixable for matplotlib 3.5 and newer, it is much harder (dare I say, not worth it) for older versions, because SymLogNorm object do not expose the log base they are using, not even in private attributes.

I'll be working on a fix within the assumption that dropping support for Matplotlib 3.2, 3.3 and 3.4 is now acceptable (albeit an unresolved conversation, see #4379).

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

Successfully merging a pull request may close this issue.

1 participant