|
12 | 12 |
|
13 | 13 |
|
14 | 14 | import numpy as np
|
| 15 | +from numpy import random |
15 | 16 |
|
16 | 17 | from numpy.testing import assert_array_equal
|
17 | 18 | from numpy.testing.decorators import slow
|
@@ -947,6 +948,38 @@ def test_grouped_hist(self):
|
947 | 948 | self.assertRaises(AttributeError, plotting.grouped_hist, df.A,
|
948 | 949 | by=df.C, foo='bar')
|
949 | 950 |
|
| 951 | + @slow |
| 952 | + def test_axis_shared(self): |
| 953 | + # GH4089 |
| 954 | + import matplotlib.pyplot as plt |
| 955 | + def tick_text(tl): |
| 956 | + return [x.get_text() for x in tl] |
| 957 | + |
| 958 | + n = 100 |
| 959 | + df = DataFrame({'gender': np.array(['Male', 'Female'])[random.randint(2, size=n)], |
| 960 | + 'height': random.normal(66, 4, size=n), |
| 961 | + 'weight': random.normal(161, 32, size=n)}) |
| 962 | + ax1, ax2 = df.hist(column='height', by=df.gender, sharex=True) |
| 963 | + self.assert_(ax1._shared_x_axes.joined(ax1, ax2)) |
| 964 | + self.assertFalse(ax1._shared_y_axes.joined(ax1, ax2)) |
| 965 | + self.assert_(ax2._shared_x_axes.joined(ax1, ax2)) |
| 966 | + self.assertFalse(ax2._shared_y_axes.joined(ax1, ax2)) |
| 967 | + plt.close('all') |
| 968 | + |
| 969 | + ax1, ax2 = df.hist(column='height', by=df.gender, sharey=True) |
| 970 | + self.assertFalse(ax1._shared_x_axes.joined(ax1, ax2)) |
| 971 | + self.assert_(ax1._shared_y_axes.joined(ax1, ax2)) |
| 972 | + self.assertFalse(ax2._shared_x_axes.joined(ax1, ax2)) |
| 973 | + self.assert_(ax2._shared_y_axes.joined(ax1, ax2)) |
| 974 | + plt.close('all') |
| 975 | + |
| 976 | + ax1, ax2 = df.hist(column='height', by=df.gender, sharex=True, |
| 977 | + sharey=True) |
| 978 | + self.assert_(ax1._shared_x_axes.joined(ax1, ax2)) |
| 979 | + self.assert_(ax1._shared_y_axes.joined(ax1, ax2)) |
| 980 | + self.assert_(ax2._shared_x_axes.joined(ax1, ax2)) |
| 981 | + self.assert_(ax2._shared_y_axes.joined(ax1, ax2)) |
| 982 | + |
950 | 983 | def test_option_mpl_style(self):
|
951 | 984 | set_option('display.mpl_style', 'default')
|
952 | 985 | set_option('display.mpl_style', None)
|
|
0 commit comments