Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Improve(?) implementation of secondary_axis.#14463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -34,4 +34,25 @@ | ||
ax.axis["right2"].label.set_text("Label Y2") | ||
ax.plot([-2, 3, 2]) | ||
############################################################################### | ||
# Or, without axisartist, one can use secondary axes to add the additional | ||
# axes: | ||
fig, ax = plt.subplots() | ||
fig.subplots_adjust(right=0.85) | ||
ax.spines["top"].set_visible(False) | ||
ax.spines["right"].set_visible(False) | ||
ax1 = ax.secondary_xaxis(0) | ||
ax1.spines["bottom"].set_position(("data", 0)) | ||
ax1.set_xlabel("Axis Zero") | ||
ax2 = ax.secondary_yaxis(1) | ||
ax2.spines["right"].set_position(("outward", 20)) | ||
ax2.set_ylabel("Label Y2") | ||
ax.plot([-2, 3, 2]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. OK, this is nice. Can this be added as an example in the main spines section as well? Or moved there, with a link to it here? Putting this second in this section makes it look like this is a deprecated way to do it, whereas I think the goal is for it to be the canonical way. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I removed the additions to simple_axisline2 and simple_axisartist1 and just linked themhttps://matplotlib.org/devdocs/gallery/ticks_and_spines/spine_placement_demo.html#sphx-glr-gallery-ticks-and-spines-spine-placement-demo-py instead. I think I'll leave the multi-axes example as it is right now because there's no completely equivalent example elsewhere and I don't want to bother about proper explanations for now, but we can always move it there later (e.g. when we kill SubplotZero...). | ||
plt.show() |