FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Tweak secondary_{x,y}axis docs. by anntzer · Pull Request #31405 · matplotlib/matplotlib · GitHub

Repository navigation

Tweak secondary_{x,y}axis docs. - #31405

Merged
QuLogic merged 1 commit into
matplotlib:mainfrom
anntzer:saxd
Mar 28, 2026
Merged

QuLogic merged 1 commit into
matplotlib:mainfrom
anntzer:saxd

Conversation

anntzer commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Use a full sentence with a principal clause. Also, the data is not plotted on the x- or y-axis; it is the scale that is on the x- or y-axis.

PR summary

AI Disclosure

PR checklist

jklymak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Small suggestion though I wonder if this is even an example or the by far predominant use

Comment thread lib/matplotlib/axes/_axes.py Outdated

For example if we want to have a second scale for the data plotted on
the xaxis.
This axis can e.g. display a second x-scale for the data plotted on the Axes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
This axis can e.g. display a second x-scale for the data plotted on the Axes.
This axis can, for example, display a second x-scale for the data plotted on the Axes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Given the discussion below, I reworded to "is typically used to...". Let me know if you want to stick to "for example".

Comment thread lib/matplotlib/axes/_axes.py Outdated

For example if we want to have a second scale for the data plotted on
the yaxis.
This axis can e.g. display a second y-scale for the data plotted on the Axes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
This axis can e.g. display a second y-scale for the data plotted on the Axes.
This axis can, for example, display a second y-scale for the data plotted on the Axes.

timhoffm commented Mar 27, 2026 •
edited
Loading

Copy link
Copy Markdown
Member

I think this is the only use. The secondary axis is coupled to the primary axis through a functional relationship.

Side question: Is it ever intended to add data to the Axes created by secondary_xaxis? Likely not as the yticks are removed, so that we don't have a visual scale for that data. Also we don't have an example on using this.

The "Returns" section could be amended by something like

The returned Axes is overlaid on top of the original Axes and all components except for the complementary axis are hidden. You may modify the complementary axis, e.g. by setting ticks or an axis label. However, it is not designed to hold data.


On a general note, this concept is a bit of a crutch. It would be better to allow secondary Axis objects on Axes instead of creating a full separate Axes instance and hiding everything we don't need. But that'd be a substantial change which we are not going to make any time soon if ever. So the solution is here to stay. It's been marked as experimental since 3.1. I'm fine with keeping that on the basis that it's not a great design, but OTOH it's been around for a long time and we are not likely to change it, so we could as well remove the experimental status. There are about 3k usages (https://github.com/search?q=%2Fsecondary_%5Bxy%5Daxis%5C%28%2F+language%3APython+NOT+is%3Afork&type=code), so it's not too much but also not negligible, so that we may not want to break them even if we technically could due to the experimental status.

Use a full sentence with a principal clause.  Also, the data is not
plotted on the x- or y-axis; it is the scale that is on the x- or
y-axis.
QuLogic added this to the v3.11.0 milestone Mar 28, 2026
QuLogic merged commit 30c3d78 into matplotlib:main Mar 28, 2026
40 of 41 checks passed
timhoffm added a commit to timhoffm/matplotlib that referenced this pull request Mar 28, 2026
anntzer deleted the saxd branch March 28, 2026 08:05
QuLogic pushed a commit that referenced this pull request Mar 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL