← 输入框|github.com|刷新
Skip to content

tight_layout : automatic adjustment of subplot params - #124

Merged
leejjoon merged 14 commits into
matplotlib:masterfrom
leejjoon:tightbbox
Jun 9, 2011
Merged

leejjoon merged 14 commits into
matplotlib:masterfrom
leejjoon:tightbbox

Conversation

@leejjoon

Copy link
Copy Markdown
Contributor

This is a patch motivated by Tony Yu's work (http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/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

mdboom commented May 24, 2011

Copy link
Copy Markdown
Member

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?

Comment thread lib/matplotlib/axis.py Outdated

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

mdboom commented May 24, 2011

Copy link
Copy Markdown
Member

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...)

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

mdboom commented May 30, 2011

Copy link
Copy Markdown
Member

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

@mdboom

mdboom commented May 31, 2011

Copy link
Copy Markdown
Member

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/matplotlib-users@lists.sourceforge.net/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