-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Description
Problem
At the moment, the default format strings in colorbar are old style ones, as in their init there is:
matplotlib/lib/matplotlib/colorbar.py
Lines 489 to 492 in 67e1814
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,
matplotlib/lib/matplotlib/colorbar.py
Line 801 in 67e1814
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