8000 Fixes issue #966: When appending the new axes, there is a bug where it by cimarronm · Pull Request #2735 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Fixes issue #966: When appending the new axes, there is a bug where it #2735

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 3 commits into from
Mar 20, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2014-03-17 Bug was fixed in append_axes from the AxesDivider class would not
append axes in the right location with respect to the reference
locator axes

2014-03-13 Add parameter 'clockwise' to function pie, True by default.

2014-27-02 Implemented separate horizontal/vertical axes padding to the
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1310,6 +1310,7 @@ def tk_window_focus():
'matplotlib.tests.test_arrow_patches',
'matplotlib.tests.test_artist',
'matplotlib.tests.test_axes',
'matplotlib.tests.test_axes_grid1',
'matplotlib.tests.test_backend_pdf',
'matplotlib.tests.test_backend_pgf',
'matplotlib.tests.test_backend_ps',
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3,563 changes: 3,563 additions & 0 deletions lib/matplotlib/tests/baseline_images/test_axes_grid1/divider_append_axes.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions lib/matplotlib/tests/test_axes_grid1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import six

import matplotlib.pyplot as plt
from matplotlib.testing.decorators import image_comparison
from mpl_toolkits.axes_grid1 import make_axes_locatable
import numpy as np


@image_comparison(baseline_images=['divider_append_axes'])
def test_divider_append_axes():

# the random data
np.random.seed(0)
x = np.random.randn(1000)
y = np.random.randn(1000)

fig, axScatter = plt.subplots()

# the scatter plot:
axScatter.scatter(x, y)

# create new axes on the right and on the top of the current axes
# The first argument of the new_vertical(new_horizontal) method is
# the height (width) of the axes to be created in inches.
divider = make_axes_locatable(axScatter)
axHistbot = divider.append_axes("bottom", 1.2, pad=0.1, sharex=axScatter)
axHistright = divider.append_axes("right", 1.2, pad=0.1, sharey=axScatter)
axHistleft = divider.append_axes("left", 1.2, pad=0.1, sharey=axScatter)
axHisttop = divider.append_axes("top", 1.2, pad=0.1, sharex=axScatter)

# now determine nice limits by hand:
binwidth = 0.25
xymax = np.max([np.max(np.fabs(x)), np.max(np.fabs(y))])
lim = (int(xymax/binwidth) + 1) * binwidth

bins = np.arange(-lim, lim + binwidth, binwidth)
axHisttop.hist(x, bins=bins)
axHistbot.hist(x, bins=bins)
axHistleft.hist(y, bins=bins, orientation='horizontal')
axHistright.hist(y, bins=bins, orientation='horizontal')

axHistbot.invert_yaxis()
axHistleft.invert_xaxis()

axHisttop.xaxis.set_ticklabels(())
axHistbot.xaxis.set_ticklabels(())
axHistleft.yaxis.set_ticklabels(())
axHistright.yaxis.set_ticklabels(())

if __name__ == '__main__':
import nose
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)
8 changes: 4 additions & 4 deletions lib/mpl_toolkits/axes_grid1/axes_divider.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,10 +554,10 @@ def new_horizontal(self, size, pad=None, pack_start=False, **kwargs):
if pack_start:
self._horizontal.insert(0, size)
self._xrefindex += 1
locator = self.new_locator(nx=0, ny=0)
locator = self.new_locator(nx=0, ny=self._yrefindex)
else:
self._horizontal.append(size)
locator = self.new_locator(nx=len(self._horizontal)-1, ny=0)
locator = self.new_locator(nx=len(self._horizontal)-1, ny=self._yrefindex)

ax = self._get_new_axes(**kwargs)
ax.set_axes_locator(locator)
Expand Down Expand Up @@ -601,10 +601,10 @@ def new_vertical(self, size, pad=None, pack_start=False, **kwargs):
if pack_start:
self._vertical.insert(0, size)
self._yrefindex += 1
locator = self.new_locator(nx=0, ny=0)
locator = self.new_locator(nx=self._xrefindex, ny=0)
else:
self._vertical.append(size)
locator = self.new_locator(nx=0, ny=len(self._vertical)-1)
locator = self.new_locator(nx=self._xrefindex, ny=len(self._vertical)-1)

ax = self._get_new_axes(**kwargs)
ax.set_axes_locator(locator)
Expand Down
0