Thanks to visit codestin.com
Credit goes to github.com

Skip to content

tight_layout : automatic adjustment of subplot params #124

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

Merged
merged 14 commits into from
Jun 9, 2011

Conversation

leejjoon
Copy link
Contributor

This is a patch motivated by Tony Yu's work (http://www.mail-archive.com/[email protected]/msg18107.html). The basic idea is same while implemented slight differently.

  • no drawing is necessary
  • support subplots that span multiple rows/columns

I also worked on simple guide that demonstrate its functionality (tight_layout_guide.rst). The html copy is here (any help with the documentation will be appreciated).

http://dl.dropbox.com/u/178748/Tight%20Layout%20guide%20%E2%80%94%20Matplotlib%20v1.1.0%20documentation.html

@mdboom
Copy link
Member

mdboom commented May 24, 2011

From reading the docs (haven't read the code yet), I'm wondering if there isn't a way around the final limitation (about colorbars). Why does the layout code only work on Subplot subclasses, and not all Axes subclasses?

@@ -888,7 +888,7 @@ class Axis(artist.Artist):
for tick in zip(*group):
yield tick

def get_ticklabel_extents(self, renderer):
def get_ticklabel_extents_old(self, renderer):
Copy link
Member

Choose a reason for hiding this comment

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

Is there a good reason to keep this around? It looks like the new version is mainly just a refactoring into get_ticklabel_extents and _get_tick_bboxes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. I meant to remove it when refactoring is done. And I just removed it. Thanks.

@leejjoon
Copy link
Contributor Author

The reason that it only supports subplots is because it is easy.
For subplots, the number of parameter you need to adjust is always 6 (left, bottom, right, top, hspace, wspace), regardless of the number subplots. For axes, on the other hand, the number of parameters are 4 x number of axes.

In general, I don't think we can figure out the intention of the users when they specified the positions of axes. If you (or others) have any idea or suggestions, let me know.

@mdboom
Copy link
Member

mdboom commented May 24, 2011

I see. That makes sense. It still would be nice to handle colorbars in a more intuitive way if possible. (Of course, I have no bright ideas right now...)

plt.show()



Copy link
Member

Choose a reason for hiding this comment

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

These examples should probably also be included as regression tests.

@leejjoon
Copy link
Contributor Author

I thought about the issue with colorbar and came up with #126. With this (and w/ above commit f216d0d), tight_layout works for colobar as far as the colorbar is created with use_gridspec=True (the layout may not be tight enough though).

@leejjoon
Copy link
Contributor Author

I added tests for tight_layout.
However, in my current setup, most of tests (especially the png ones) are currently failing, thus I haven't added any baseline images yet. Do tests run okay for others?

@mdboom
Copy link
Member

mdboom commented May 30, 2011

Ah yes. I'm seeing a lot of failures as well. I should hopefully have some time to look into this tomorrow.

@mdboom
Copy link
Member

mdboom commented May 31, 2011

See #129 for a fix to most of the regression tests.

leejjoon added a commit that referenced this pull request Jun 9, 2011
---


This is a patch motivated by Tony Yus work (http://www.mail-archive.com/[email protected]/msg18107.html). The basic idea is same while implemented slight differently.

 * no drawing is necessary
 * support subplots that span multiple rows/columns

I also worked on simple guide that demonstrate its functionality (tight_layout_guide.rst). The html copy is here (any help with the documentation will be appreciated).

http://dl.dropbox.com/u/178748/Tight%20Layout%20guide%20%E2%80%94%20Matplotlib%20v1.1.0%20documentation.html
@leejjoon leejjoon merged commit f2f212e into matplotlib:master Jun 9, 2011
@richbwood richbwood mentioned this pull request Dec 19, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants