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

Appearance settings

Commit aaa2970

Browse filesBrowse files
committed
Merge pull request matplotlib#2735 from cimarronm/divider_append_axes_fix
Fixes issue matplotlib#966: When appending the new axes, there is a bug where it
2 parents d33e5b9 + 8282498 commit aaa2970
Copy full SHA for aaa2970

File tree

Expand file treeCollapse file tree

7 files changed

+3627
-4
lines changed
Filter options
Expand file treeCollapse file tree

7 files changed

+3627
-4
lines changed

‎CHANGELOG

Copy file name to clipboardExpand all lines: CHANGELOG
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2014-03-17 Bug was fixed in append_axes from the AxesDivider class would not
2+
append axes in the right location with respect to the reference
3+
locator axes
4+
15
2014-03-13 Add parameter 'clockwise' to function pie, True by default.
26

37
2014-27-02 Implemented separate horizontal/vertical axes padding to the

‎lib/matplotlib/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/__init__.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,6 +1310,7 @@ def tk_window_focus():
13101310
'matplotlib.tests.test_arrow_patches',
13111311
'matplotlib.tests.test_artist',
13121312
'matplotlib.tests.test_axes',
1313+
'matplotlib.tests.test_axes_grid1',
13131314
'matplotlib.tests.test_backend_pdf',
13141315
'matplotlib.tests.test_backend_pgf',
13151316
'matplotlib.tests.test_backend_ps',
Binary file not shown.
Loading

‎lib/matplotlib/tests/baseline_images/test_axes_grid1/divider_append_axes.svg

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/baseline_images/test_axes_grid1/divider_append_axes.svg
+3,563Lines changed: 3563 additions & 0 deletions
Loading
+55Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
from __future__ import (absolute_import, division, print_function,
2+
unicode_literals)
3+
4+
import six
5+
6+
import matplotlib.pyplot as plt
7+
from matplotlib.testing.decorators import image_comparison
8+
from mpl_toolkits.axes_grid1 import make_axes_locatable
9+
import numpy as np
10+
11+
12+
@image_comparison(baseline_images=['divider_append_axes'])
13+
def test_divider_append_axes():
14+
15+
# the random data
16+
np.random.seed(0)
17+
x = np.random.randn(1000)
18+
y = np.random.randn(1000)
19+
20+
fig, axScatter = plt.subplots()
21+
22+
# the scatter plot:
23+
axScatter.scatter(x, y)
24+
25+
# create new axes on the right and on the top of the current axes
26+
# The first argument of the new_vertical(new_horizontal) method is
27+
# the height (width) of the axes to be created in inches.
28+
divider = make_axes_locatable(axScatter)
29+
axHistbot = divider.append_axes("bottom", 1.2, pad=0.1, sharex=axScatter)
30+
axHistright = divider.append_axes("right", 1.2, pad=0.1, sharey=axScatter)
31+
axHistleft = divider.append_axes("left", 1.2, pad=0.1, sharey=axScatter)
32+
axHisttop = divider.append_axes("top", 1.2, pad=0.1, sharex=axScatter)
33+
34+
# now determine nice limits by hand:
35+
binwidth = 0.25
36+
xymax = np.max([np.max(np.fabs(x)), np.max(np.fabs(y))])
37+
lim = (int(xymax/binwidth) + 1) * binwidth
38+
39+
bins = np.arange(-lim, lim + binwidth, binwidth)
40+
axHisttop.hist(x, bins=bins)
41+
axHistbot.hist(x, bins=bins)
42+
axHistleft.hist(y, bins=bins, orientation='horizontal')
43+
axHistright.hist(y, bins=bins, orientation='horizontal')
44+
45+
axHistbot.invert_yaxis()
46+
axHistleft.invert_xaxis()
47+
48+
axHisttop.xaxis.set_ticklabels(())
49+
axHistbot.xaxis.set_ticklabels(())
50+
axHistleft.yaxis.set_ticklabels(())
51+
axHistright.yaxis.set_ticklabels(())
52+
53+
if __name__ == '__main__':
54+
import nose
55+
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

‎lib/mpl_toolkits/axes_grid1/axes_divider.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axes_grid1/axes_divider.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -554,10 +554,10 @@ def new_horizontal(self, size, pad=None, pack_start=False, **kwargs):
554554
if pack_start:
555555
self._horizontal.insert(0, size)
556556
self._xrefindex += 1
557-
locator = self.new_locator(nx=0, ny=0)
557+
locator = self.new_locator(nx=0, ny=self._yrefindex)
558558
else:
559559
self._horizontal.append(size)
560-
locator = self.new_locator(nx=len(self._horizontal)-1, ny=0)
560+
locator = self.new_locator(nx=len(self._horizontal)-1, ny=self._yrefindex)
561561

562562
ax = self._get_new_axes(**kwargs)
563563
ax.set_axes_locator(locator)
@@ -601,10 +601,10 @@ def new_vertical(self, size, pad=None, pack_start=False, **kwargs):
601601
if pack_start:
602602
self._vertical.insert(0, size)
603603
self._yrefindex += 1
604-
locator = self.new_locator(nx=0, ny=0)
604+
locator = self.new_locator(nx=self._xrefindex, ny=0)
605605
else:
606606
self._vertical.append(size)
607-
locator = self.new_locator(nx=0, ny=len(self._vertical)-1)
607+
locator = self.new_locator(nx=self._xrefindex, ny=len(self._vertical)-1)
608608

609609
ax = self._get_new_axes(**kwargs)
610610
ax.set_axes_locator(locator)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.