Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[ENH]: use new style format strings for colorbar ticks #21378

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

Closed
TLouf opened this issue Oct 18, 2021 · 0 comments · Fixed by #21542
Closed

[ENH]: use new style format strings for colorbar ticks #21378

TLouf opened this issue Oct 18, 2021 · 0 comments · Fixed by #21542
Milestone

Comments

@TLouf
Copy link

TLouf commented Oct 18, 2021

Problem

At the moment, the default format strings in colorbar are old style ones, as in their init there is:

if isinstance(format, str):
self.formatter = ticker.FormatStrFormatter(format)
else:
self.formatter = format # Assume it is a Formatter or None

which is a different convention from the one of a normal axis, which was introduced in #16715.

Proposed solution

As in update_ticks we pass the colorbar's formatter to the long axis,

self._long_axis().set_major_formatter(self.formatter)

the if statement above may be removed to keep the default logic only in Axis. Right now one can pass a callable directly (although that's not documented), and the default behaviour from #16715 is triggered. However, I guess making this change for format strings would imply a deprecation cycle, as it breaks current behaviour. Another option would be to check in Axis._set_formatter for what kind of string format we've been passed (unsure how, although there must be way).

Additional context and prior art

No response

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.

2 participants