-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Demonstrate inset_axes in scatter_hist example. #21283
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
it is a valid way/I abuse inset axes a lot/I think it's okay since you're not removing the other one ways to do it - though I wonder then if there should be a top line explicit
For each method so it doesn't read like 5 ways to do the same thing. |
Reworded. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me other than a couple of minor suggestions below. Thanks!
# Despite its name, `~.Axes.inset_axes` can also be used to position marginals | ||
# *outside* the main axes. The advantage of doing so is that the aspect ratio | ||
# of the main axes can be fixed, regardless of the figure size. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Despite its name, `~.Axes.inset_axes` can also be used to position marginals | |
# *outside* the main axes. The advantage of doing so is that the aspect ratio | |
# of the main axes can be fixed, regardless of the figure size. | |
# `~.Axes.inset_axes` can be used to position marginals | |
# *outside* the main axes. The advantage of doing so is that the aspect ratio | |
# of the main axes can be fixed, and the marginals will always be drawn relative | |
# to the position of the axes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
ax_histx = ax.inset_axes([0, 1.05, 1, 0.25], sharex=ax) | ||
ax_histy = ax.inset_axes([1.05, 0, 0.25, 1], sharey=ax) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You uses 2/7 before = 0.285. Is there a reason to use 0.25 here? Probably insignificant, but maybe change them to be the same?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switched to 4:1 everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style nits, can be merged w/ or w/o changes
|
||
An alternative method to produce a similar figure using the ``axes_grid1`` | ||
toolkit is shown in the | ||
:doc:`/gallery/axes_grid1/scatter_hist_locatable_axes` example. | ||
:doc:`/gallery/axes_grid1/scatter_hist_locatable_axes` example. Finally, it is | ||
also possible to simply position all axes in absolute coordinates using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also possible to simply position all axes in absolute coordinates using | |
also possible to position all axes in absolute coordinates using |
|
||
* the axes positions are defined in terms of rectangles in figure coordinates | ||
* the axes positions are defined via a gridspec | ||
* the axes positions are defined via a gridspec; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe use
.. contents::
:local:
to have links.
@@ -121,5 +119,6 @@ def scatter_hist(x, y, ax, ax_histx, ax_histy): | |||
# - `matplotlib.figure.Figure.add_axes` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# - `matplotlib.figure.Figure.add_axes` |
not used anymore.
Currently, the scatter_hist example needs to force the main axes to be square by carefully adjusting the figure size -- shared axes and fixed aspects don't work well together (and manually resizing the figure shows that the aspect is indeed not fixed). In fact, the scatter_hist_locatable_axes example explicitly states that the advantage of using axes_grid1 is to allow the aspect to be fixed. I realized that one can also use inset_axes to position the marginals axes relative to the main axes *and* support a fixed aspect ratio for the main axes. Perhaps this can be considered as a slight API abuse, but I think this is a solution for a real limitation; the question is whether we want to promote this use?
thanks, all comments handled |
Demonstrate inset_axes in scatter_hist example.
Currently, the scatter_hist example needs to force the main axes to be
square by carefully adjusting the figure size -- shared axes and fixed
aspects don't work well together (and manually resizing the figure shows
that the aspect is indeed not fixed). In fact, the
scatter_hist_locatable_axes example explicitly states that the advantage
of using axes_grid1 is to allow the aspect to be fixed.
I realized that one can also use inset_axes to position the marginals
axes relative to the main axes and support a fixed aspect ratio for
the main axes. Perhaps this can be considered as a slight API abuse,
but I think this is a solution for a real limitation; the question is
whether we want to promote this use?
PR Summary
PR Checklist
pytest
passes).flake8
on changed files to check).flake8-docstrings
and runflake8 --docstring-convention=all
).doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).