Skip to content

Commit 1175933

Browse files
nrebenajreback
authored andcommitted
CLN: Removing dead code in plotting and minor refactoring (#26260)
1 parent d49ebd4 commit 1175933

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

pandas/plotting/_core.py

+14-20
Original file line numberDiff line numberDiff line change
@@ -401,22 +401,8 @@ def _add_table(self):
401401

402402
def _post_plot_logic_common(self, ax, data):
403403
"""Common post process for each axes"""
404-
from matplotlib.ticker import FixedLocator, FixedFormatter
405-
406-
def get_label(i):
407-
try:
408-
return pprint_thing(data.index[i])
409-
except Exception:
410-
return ''
411404

412405
if self.orientation == 'vertical' or self.orientation is None:
413-
if self._need_to_set_index:
414-
xticks = ax.get_xticks()
415-
xticklabels = [get_label(x) for x in xticks]
416-
ax.set_xticklabels(xticklabels)
417-
ax.xaxis.set_major_locator(FixedLocator(xticks))
418-
ax.xaxis.set_major_formatter(FixedFormatter(xticklabels))
419-
420406
self._apply_axis_properties(ax.xaxis, rot=self.rot,
421407
fontsize=self.fontsize)
422408
self._apply_axis_properties(ax.yaxis, fontsize=self.fontsize)
@@ -426,12 +412,6 @@ def get_label(i):
426412
fontsize=self.fontsize)
427413

428414
elif self.orientation == 'horizontal':
429-
if self._need_to_set_index:
430-
yticks = ax.get_yticks()
431-
yticklabels = [get_label(y) for y in yticks]
432-
ax.set_yticklabels(yticklabels)
433-
ax.xaxis.set_major_locator(FixedLocator(yticks))
434-
ax.xaxis.set_major_formatter(FixedFormatter(yticklabels))
435415
self._apply_axis_properties(ax.yaxis, rot=self.rot,
436416
fontsize=self.fontsize)
437417
self._apply_axis_properties(ax.xaxis, fontsize=self.fontsize)
@@ -1115,6 +1095,20 @@ def _update_stacker(cls, ax, stacking_id, values):
11151095
ax._stacker_neg_prior[stacking_id] += values
11161096

11171097
def _post_plot_logic(self, ax, data):
1098+
from matplotlib.ticker import FixedLocator
1099+
1100+
def get_label(i):
1101+
try:
1102+
return pprint_thing(data.index[i])
1103+
except Exception:
1104+
return ''
1105+
1106+
if self._need_to_set_index:
1107+
xticks = ax.get_xticks()
1108+
xticklabels = [get_label(x) for x in xticks]
1109+
ax.set_xticklabels(xticklabels)
1110+
ax.xaxis.set_major_locator(FixedLocator(xticks))
1111+
11181112
condition = (not self._use_dynamic_x() and
11191113
data.index.is_all_dates and
11201114
not self.subplots or

0 commit comments

Comments
 (0)