Skip to content

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

Closed
@TLouf

Description

@TLouf

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions