Skip to content

Commit a6d791c

Browse files
committed
Removing variable custom_tick_pos and adding test
1 parent 2bcf920 commit a6d791c

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

doc/source/whatsnew/v0.25.2.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ I/O
6969
Plotting
7070
^^^^^^^^
7171

72-
- Fixed xticks in :core.py: `BarPlot._post_plot_logic` when setting a custom xticks
72+
-
7373
-
7474
-
7575

doc/source/whatsnew/v1.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ Plotting
171171
- Bug in :meth:`DataFrame.plot` producing incorrect legend markers when plotting multiple series on the same axis (:issue:`18222`)
172172
- Bug in :meth:`DataFrame.plot` when ``kind='box'`` and data contains datetime or timedelta data. These types are now automatically dropped (:issue:`22799`)
173173
- Bug in :meth:`DataFrame.plot.line` and :meth:`DataFrame.plot.area` produce wrong xlim in x-axis (:issue:`27686`, :issue:`25160`, :issue:`24784`)
174+
- Bug in :core.py:`BarPlot._decorate_ticks` xticks argument has no effect in bar plot (:issue:`14119`)
174175

175176
Groupby/resample/rolling
176177
^^^^^^^^^^^^^^^^^^^^^^^^

pandas/plotting/_matplotlib/core.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,6 @@ def __init__(self, data, **kwargs):
13101310
pos = kwargs.pop("position", 0.5)
13111311
kwargs.setdefault("align", "center")
13121312
self.tick_pos = np.arange(len(data))
1313-
self.custom_tick_pos = kwargs.pop("xticks", None)
13141313

13151314
self.bottom = kwargs.pop("bottom", 0)
13161315
self.left = kwargs.pop("left", 0)
@@ -1437,8 +1436,8 @@ def _post_plot_logic(self, ax, data):
14371436
def _decorate_ticks(self, ax, name, ticklabels, start_edge, end_edge):
14381437
ax.set_xlim((start_edge, end_edge))
14391438

1440-
if self.custom_tick_pos is not None:
1441-
ax.set_xticks(np.array(self.custom_tick_pos))
1439+
if self.xticks is not None:
1440+
ax.set_xticks(np.array(self.xticks))
14421441
else:
14431442
ax.set_xticks(self.tick_pos)
14441443
ax.set_xticklabels(ticklabels)

pandas/tests/plotting/test_series.py

+7
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,13 @@ def test_xticklabels(self):
871871
exp = ["P{i:02d}".format(i=i) for i in [0, 3, 5, 9]]
872872
self._check_text_labels(ax.get_xticklabels(), exp)
873873

874+
def test_xtick_barPlot(self):
875+
# GH28172
876+
s = pd.Series(range(10), index=["P{i:02d}".format(i=i) for i in range(10)])
877+
ax = s.plot.bar(xticks=range(0, 11, 2))
878+
exp = np.array(list(range(0, 11, 2)))
879+
assert (exp == ax.get_xticks()).all()
880+
874881
def test_custom_business_day_freq(self):
875882
# GH7222
876883
from pandas.tseries.offsets import CustomBusinessDay

0 commit comments

Comments
 (0)