Demonstrate inset_axes in scatter_hist example.#21283
Demonstrate inset_axes in scatter_hist example.#21283story645 merged 1 commit intomatplotlib:masterfrom
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. |
jklymak
left a comment
There was a problem hiding this comment.
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.
| # 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. |
| 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.
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.
switched to 4:1 everywhere.
story645
left a comment
There was a problem hiding this comment.
style nits, can be merged w/ or w/o changes
| 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.
| 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.
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.
| # - `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
pytestpasses).flake8on changed files to check).flake8-docstringsand 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).