Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add public API for setting an axis unit converter #19229

Closed
Assignees
tacaswellksunden
Milestone
@mwaskom

Description

@mwaskom

Problem

I would like to define and use a custom unit converter class. The existingmpl.units.registry system is type-based, which does not work for my usecase. I need my converter to generalize over types. But I also know exactly which (existing) axis objects should use the converter.

The closest I can get in associating a custom converter with an existing axis, following the code inaxis.update_units is

ax=plt.figure().subplots()ax.xaxis.converter=CustomConverter()ax.xaxis._update_axisinfo()ax.xaxis.stale=True

Proposed Solution

A publicaxis.set_converter API would solve this problem, e.g.

ax=plt.figure().subplots()ax.set_converter(CustomConverter())

The idea is that this would basically do whatAxis.update_units does, but consuming aConversionInterface rather than consuming data and then getting a converter from the registry.

Additional context and prior art

The other thing I would mention is that I could probably work-around this problem if the registry lookup were based on the containerdtype rather than the type of the individual elements (as is currently the case). But that seems to complexify the existing API, whereas the this proposal would add an orthogonal API, and it is probably better for that reason.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp