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

[mpl_toolkits] Allow "figure" kwarg for host functions in parasite_axes#4863

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

Conversation

smheidrich
Copy link
Contributor

Currently,host_axes andhost_subplot ofmpl_toolkits.axes_grid1 work onpyplot only. This patch allows a kwargfigure (defaulting topyplot.gcf()) to be passed so it becomes possible to use them on arbitrary figures as well.

@@ -487,7 +487,10 @@ def host_axes(*args, **kwargs):
import matplotlib.pyplot as plt
axes_class = kwargs.pop("axes_class", None)
host_axes_class = host_axes_class_factory(axes_class)
fig = plt.gcf()
if kwargs.get("figure") != None:
Copy link
Member

Choose a reason for hiding this comment

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

don't do equality comparison toNone. Always dois andis not.

@WeatherGod
Copy link
Member

Also needs documentation (although, I am not clear where...). Besides the equality comment, this makes sense to me. Don't know why it wasn't coded that way before...

@smheidrich
Copy link
ContributorAuthor

@WeatherGod thanks for your correction. Both of these functions weren't documented (except for their usage in examples) to begin with, so I'm not sure either. The whole AxesGrid toolkit seems a bit neglected to me, do people still use it?

@WeatherGod
Copy link
Member

Oh, absolutely it gets used. It is one of the more popular toolkits.

On Tue, Aug 4, 2015 at 5:23 PM, productivememberofsociety666 <
notifications@github.com> wrote:

@WeatherGodhttps://github.com/WeatherGod thanks for your correction.
Both of these functions weren't documented (except for their usage in
examples) to begin with, so I'm not sure either. The whole AxesGrid toolkit
seems a bit neglected to me, do people still use it?


Reply to this email directly or view it on GitHub
#4863 (comment)
.

@dopplershift
Copy link
Contributor

Someone else just contributed some docs:#4864

@WeatherGod
Copy link
Member

In fact, you might be interested in#4864 (just submitted) where someone gives some love to the documentation.

import matplotlib.pyplot as plt
axes_class = kwargs.pop("axes_class", None)
host_axes_class = host_axes_class_factory(axes_class)
fig = plt.gcf()
if kwargs.get("figure") is not None:
Copy link
Member

Choose a reason for hiding this comment

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

I would do this as

fig=kwargs.get('figure',None)iffigisNone:fig=plt.gcf()

@tacaswelltacaswell added this to theproposed next point release milestoneAug 5, 2015
@tacaswell
Copy link
Member

Sorry this languished, in the future leave a comment after you finish with edits. We don't get notifications on commit pushes, just comments.

tacaswell added a commit that referenced this pull requestNov 5, 2015
…xes_not_pyplotENH: Allow "figure" kwarg for host functions in parasite_axes
@tacaswelltacaswell merged commitc594223 intomatplotlib:masterNov 5, 2015
@tacaswell
Copy link
Member

This isn't perfect, but does not make it worse.

@FilipDominec
Copy link

Could you, please, point me to a minimum example of usinghost_axes once

self.fig=matplotlib.figure.Figure(figsize=(8,8))

is defined?

@smheidrich
Copy link
ContributorAuthor

smheidrich commentedSep 30, 2016
edited
Loading

@FilipDominec

hax=host_axes([0.1,0.1,0.8,0.8],figure=fig)hax.plot([0,1,2,3],[1,2,4,8])fig.savefig("some_file.png")

Result looks very broken though, even when I setfigure=plt.gcf() (which is weird because nothing else happens inside the function whenfigure isNone).

I'm usinghost_subplot withfigure kwarg in my own projects. I think I just added the kwarg forhost_axes while I was at it because it was almost identical tohost_subplot.

FilipDominec reacted with thumbs up emoji

@FilipDominec
Copy link

@smheidrich Thanks!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
v2.1
Development

Successfully merging this pull request may close these issues.

5 participants
@smheidrich@WeatherGod@dopplershift@tacaswell@FilipDominec

[8]ページ先頭

©2009-2025 Movatter.jp