Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
story645 merged 1 commit intomatplotlib:masterfromanntzer:ia
Oct 16, 2021

Conversation

anntzer
Copy link
Contributor

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 axesand 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

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (runflake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • Conforms to Matplotlib style conventions (installflake8-docstrings and runflake8 --docstring-convention=all).
  • New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).

@story645
Copy link
Member

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

  • pro
  • con

For each method so it doesn't read like 5 ways to do the same thing.

timhoffm reacted with thumbs up emoji

@anntzer
Copy link
ContributorAuthor

Reworded.

Copy link
Member

@jklymakjklymak left a 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!

Comment on lines 87 to 89
# 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.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# 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.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

yes

Comment on lines +103 to +104
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)
Copy link
Member

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?

Copy link
ContributorAuthor

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.

Copy link
Member

@story645story645 left a 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
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
alsopossibletosimplypositionallaxesinabsolutecoordinatesusing
alsopossibletopositionallaxesinabsolutecoordinatesusing


* 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;
Copy link
Member

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`
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# - `matplotlib.figure.Figure.add_axes`

not used anymore.

Currently, the scatter_hist example needs to force the main axes to besquare by carefully adjusting the figure size -- shared axes and fixedaspects don't work well together (and manually resizing the figure showsthat the aspect is indeed not fixed).  In fact, thescatter_hist_locatable_axes example explicitly states that the advantageof using axes_grid1 is to allow the aspect to be fixed.I realized that one can also use inset_axes to position the marginalsaxes relative to the main axes *and* support a fixed aspect ratio forthe 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 iswhether we want to promote this use?
@anntzer
Copy link
ContributorAuthor

thanks, all comments handled

@story645story645 merged commita9bba75 intomatplotlib:masterOct 16, 2021
@anntzeranntzer deleted the ia branchOctober 17, 2021 07:15
@QuLogicQuLogic added this to thev3.6.0 milestoneOct 18, 2021
tacaswell pushed a commit that referenced this pull requestOct 20, 2021
Demonstrate inset_axes in scatter_hist example.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@QuLogicQuLogicQuLogic left review comments

@timhoffmtimhoffmtimhoffm left review comments

@story645story645story645 approved these changes

@jklymakjklymakjklymak approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.6.0
Development

Successfully merging this pull request may close these issues.

5 participants
@anntzer@story645@QuLogic@jklymak@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp