8000 Shared axes colorbars & finer location control by pelson · Pull Request #956 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Shared axes colorbars & finer location control #956

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 5 commits into from
May 14, 2013
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updated tests and added docstring.
  • Loading branch information
pelson committed May 14, 2013
commit 6dde4c155bab909a2f3e6bafc0626618d2a3f5db
35 changes: 33 additions & 2 deletions lib/matplotlib/colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -960,12 +960,39 @@ def update_bruteforce(self, mappable):


@docstring.Substitution(make_axes_kw_doc)
def make_axes(parents, location=None, orientation=None, fraction=0.15, shrink=1.0, aspect=20, **kw):
def make_axes(parents, location=None, orientation=None, fraction=0.15,
shrink=1.0, aspect=20, **kw):
'''
Resize and reposition parent axes, and return a child
axes suitable for a colorbar::

cax, kw = make_axes(parent, **kw)

Keyword arguments may include the following (with defaults):

*location*: [**None**|'left'|'right'|'top'|'bottom']
The position, relative to **parents**, where the colorbar axes
should be created. If None, the value will either come from the
given **orientation**, else it will default to 'right'.

*orientation*: [**None**|'vertical'|'horizontal']
The orientation of the colorbar. Typically, this keyword shouldn't
be used, as it can be derived from the **location** keyword.

%s

Returns (cax, kw), the child axes and the reduced kw dictionary to be
passed when creating the colorbar instance.
'''
locations = ["left", "right", "top", "bottom"]
if orientation is not None and location is not None:
raise TypeError('position and orientation are mutually exclusive. Consider ' \
'setting the position to any of %s' % ', '.join(locations))

# provide a default location
if location is None and orientation is None:
location = 'right'

# allow the user to not specify the location by specifying the orientation instead
if location is None:
location = 'right' if orientation == 'vertical' else 'bottom'
Expand Down Expand Up @@ -1057,6 +1084,9 @@ def make_axes_gridspec(parent, **kw):
suitable for a colorbar. This function is similar to
make_axes. Prmary differences are

* *make_axes_gridspec* only handles the *orientation* keyword
and cannot handle the "location" keyword.

* *make_axes_gridspec* should only be used with a subplot parent.

* *make_axes* creates an instance of Axes. *make_axes_gridspec*
Expand All @@ -1080,7 +1110,8 @@ def make_axes_gridspec(parent, **kw):

All but the first of these are stripped from the input kw set.

Returns (cax, kw), the child axes and the reduced kw dictionary.
Returns (cax, kw), the child axes and the reduced kw dictionary to be
passed when creating the colorbar instance.
'''

orientation = kw.setdefault('orientation', 'vertical')
Expand Down
Binary file modified lib/matplotlib/tests/baseline_images/test_colorbar/double_cbar.pdf
Binary file not shown.
Binary file modified lib/matplotlib/tests/baseline_images/test_colorbar/double_cbar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
0