Skip to content

Commit 47a831e

Browse files
committed
BUG: Fixed font size (set it on both x and y axis). #8765
1 parent 2e59e42 commit 47a831e

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

doc/source/whatsnew/v0.15.2.txt

+1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ Bug Fixes
9999
- Bug in ``BlockManager`` where setting values with different type would break block integrity (:issue:`8850`)
100100
- Bug in ``DatetimeIndex`` when using ``time`` object as key (:issue:`8667`)
101101
- Fix negative step support for label-based slices (:issue:`8753`)
102+
- Fix: The font size was only set on x axis if vertical or the y axis if horizontal. (:issue:`8765`)
102103

103104
Old behavior:
104105

pandas/tools/plotting.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1051,13 +1051,15 @@ def _adorn_subplots(self):
10511051
xticklabels = [labels.get(x, '') for x in ax.get_xticks()]
10521052
ax.set_xticklabels(xticklabels)
10531053
self._apply_axis_properties(ax.xaxis, rot=self.rot,
1054-
fontsize=self.fontsize)
1054+
fontsize=self.fontsize)
1055+
self._apply_axis_properties(ax.yaxis, fontsize=self.fontsize)
10551056
elif self.orientation == 'horizontal':
10561057
if self._need_to_set_index:
10571058
yticklabels = [labels.get(y, '') for y in ax.get_yticks()]
10581059
ax.set_yticklabels(yticklabels)
10591060
self._apply_axis_properties(ax.yaxis, rot=self.rot,
1060-
fontsize=self.fontsize)
1061+
fontsize=self.fontsize)
1062+
self._apply_axis_properties(ax.xaxis, fontsize=self.fontsize)
10611063

10621064
def _apply_axis_properties(self, axis, rot=None, fontsize=None):
10631065
labels = axis.get_majorticklabels() + axis.get_minorticklabels()

pandas/tseries/tests/test_plotting.py

+8
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ def test_ts_plot_with_tz(self):
4848
ts = Series([188.5, 328.25], index=index)
4949
_check_plot_works(ts.plot)
5050

51+
def test_fontsize_set_correctly(self):
52+
# For issue #8765
53+
import matplotlib.pyplot as plt
54+
df = DataFrame(np.random.randn(10, 9), index=range(10))
55+
ax = df.plot(fontsize=2)
56+
for label in (ax.get_xticklabels() + ax.get_yticklabels()):
57+
self.assertEqual(label.get_fontsize(), 2)
58+
5159
@slow
5260
def test_frame_inferred(self):
5361
# inferred freq

0 commit comments

Comments
 (0)