Skip to content

Commit 2bcf920

Browse files
committed
Fixing issue pandas-dev#14119
1 parent 49d2019 commit 2bcf920

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
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-
-
72+
- Fixed xticks in :core.py: `BarPlot._post_plot_logic` when setting a custom xticks
7373
-
7474
-
7575

pandas/plotting/_matplotlib/core.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -1310,6 +1310,7 @@ 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)
13131314

13141315
self.bottom = kwargs.pop("bottom", 0)
13151316
self.left = kwargs.pop("left", 0)
@@ -1435,8 +1436,13 @@ def _post_plot_logic(self, ax, data):
14351436

14361437
def _decorate_ticks(self, ax, name, ticklabels, start_edge, end_edge):
14371438
ax.set_xlim((start_edge, end_edge))
1438-
ax.set_xticks(self.tick_pos)
1439-
ax.set_xticklabels(ticklabels)
1439+
1440+
if self.custom_tick_pos is not None:
1441+
ax.set_xticks(np.array(self.custom_tick_pos))
1442+
else:
1443+
ax.set_xticks(self.tick_pos)
1444+
ax.set_xticklabels(ticklabels)
1445+
14401446
if name is not None and self.use_index:
14411447
ax.set_xlabel(name)
14421448

0 commit comments

Comments
 (0)