8000 Wishlist: functionally linked twin axes · Issue #12734 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Wishlist: functionally linked twin axes #12734
Closed
@FilipDominec

Description

@FilipDominec

While there is an elegant option of twinx/twiny for plotting two curves with two independent x or y axes into a single plot, in science one sometimes faces a different task: plotting one curve on a dual axis defined by a function.

As an example this can be an optical spectrum with bottom x-axis showing the wavelength λ in nanometers and top x-axis photon energy E in electronvolts. Note the functional dependence of these axes is nonlinear E=hc/λ. For publication, one also needs both axes to have nice, round and correctly positioned numbers, so passing this functional dependence directly into an object like xaxisformatter is out of question.

I have implemented a solution that generates correct secondary x- or y-axes, also with the possibility of logarithmic option:

https://gist.github.com/FilipDominec/9101258e8ba979c715a28bc527a43961

Since I consider this situation relatively common in scientific plotting, I suggest the 30-line long trick could be added to matplotlib for easier use by others. A real-life image featuring two pairs of functionally dependent axes follows:

e7308db2-8977-11e6-8727-da0a48d46152

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0