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

bbox_inches="tight" support for *all* figure artists.#1448

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
dmcdougall merged 2 commits intomatplotlib:masterfrompelson:bbox_tight_all_artists
Mar 31, 2013

Conversation

pelson
Copy link
Member

This is a first pass at makingbbox_inches="tight" work for anything you can throw at a figure.

I think@leejjoon implemented this functionality originally, so it would be great to get some feedback from him as to whether this is a good approach or not.

My motivation for this has been seeing all of the PRs/issues that have gone by lately relating tobbox_inches="tight", most of these have come as a result of iPython defaulting to using this setting (@fperez may be interested in this PR therefore), hopefully this should resolveall outstanding issues on that front (a lot of them have actually already been fixed with bespoke solutions, but inevitably there will be other cases which have not been specifically targeted, hence this PR).

Personally, I still feel thatbbox_inches="tight" is an ingenious hack which I would sooner see done better by a geometry manager (#1109), but in lieu of that functionality, getting this right is a worthy pragmatic short-to-medium term goal.

Thanks for your time,

@pelson
Copy link
MemberAuthor

Please note: I am working on my mac and have a couple of concerns about the fonts of the result images (that may well be unfounded). I won't be able to re-generate them with a more reliable freetype until Monday morning.

@@ -14,4 +14,4 @@ install:
script:
- mkdir ../foo
- cd ../foo
- python ../matplotlib/tests.py
- python ../matplotlib/tests.py -sv
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Note: This means we can see if any of the tests are producing standard out (if you're prepared to look at the travis log), and to determine easilywhich test is producing it.

@jenshnielsen
Copy link
Member

Looks good to me. How about getting rid of the text in the table to make the test less likely to fail with different
freetype versions. Something like the following

importmatplotlib.textastextdata= [[66386,174296,75131,577908,32015],        [58230,381139,78045,99308,160454],        [89135,80552,152558,497981,603535],        [78415,81858,150656,193263,69638],        [139361,331509,343164,781380,52269]]colLabels= ('Freeze','Wind','Flood','Quake','Hail')rowLabels= ['%d year'%xforxin (100,50,20,10,5)]rows=len(data)ind=np.arange(len(colLabels))+0.3# the x locations for the groupscellText= []width=0.4# the width of the barsyoff=np.array([0.0]*len(colLabels))cols= ['r','g','b','k','y']cols2=cols2=5*[cols]# the bottom values for stacked bar chartfig,ax=plt.subplots(1,1)forrowinxrange(rows):plt.bar(ind,data[row],width,bottom=yoff)yoff=yoff+data[row]cellText.append(['%1.1f'% (x/1000.0)forxinyoff])plt.xticks([])plt.legend(['1','2','3','4','5'],loc= (1.2,0.2))# Add a table at the bottom of the axescellText.reverse()the_table=plt.table(loc='bottom',rowColours=cols,colColours=cols,cellColours=cols2)

jenshnielsen added a commit to jenshnielsen/matplotlib that referenced this pull requestNov 21, 2012
@pelson
Copy link
MemberAuthor

@mdboom - would you mind having a look over this? If you'd rather not have this PR merged, then I won't bother rebasing and bringing it up to speed, but if you think its worthwhile I will.

Cheers,

box at 0, 0.
"""
return Bbox([[0, 0], [0, 0]])

Copy link
Member

Choose a reason for hiding this comment

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

If a subclass does not override this method. Willbbox_inches='tight' result in a figure that always contains the point(0, 0)? If so, would it be better to raiseNotImplementedError instead?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Bboxes with a width or height of 0 are not included in the final Bbox calculation, so in truth, the Bbox could be based anywhere.

@dmcdougall
Copy link
Member

I would like this to go in v1.3, it would be a lovely enhancement. Thank you for the hard work you've put into this,@pelson.

If there is consensus to include this, this PR needs aCHANGELOG a entry. A nice example would be nice, too. I like that you have tested this well! Good job.

@pelson
Copy link
MemberAuthor

Thanks Damon. I'll rebase and address your comments subsequently.

@efiring
Copy link
Member

@pelson, it looks like it would be nice to get this merged soon. I agree with your sentiments expressed in your opening comment.

@dmcdougall
Copy link
Member

There were some python 2.x build errors. I've restarted the build.

dmcdougall added a commit that referenced this pull requestMar 31, 2013
```bbox_inches="tight"``` support for *all* figure artists.
@dmcdougalldmcdougall merged commit8605579 intomatplotlib:masterMar 31, 2013
jenshnielsen added a commit to jenshnielsen/matplotlib that referenced this pull requestJun 18, 2013
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees

@dmcdougalldmcdougall

Labels
None yet
Projects
None yet
Milestone
v1.3.x
Development

Successfully merging this pull request may close these issues.

4 participants
@pelson@jenshnielsen@dmcdougall@efiring

[8]ページ先頭

©2009-2025 Movatter.jp