Skip to content

CLN: Removing dead code in plotting and minor refactoring #26260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 14 additions & 20 deletions pandas/plotting/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,22 +401,8 @@ def _add_table(self):

def _post_plot_logic_common(self, ax, data):
"""Common post process for each axes"""
from matplotlib.ticker import FixedLocator, FixedFormatter

def get_label(i):
try:
return pprint_thing(data.index[i])
except Exception:
return ''

if self.orientation == 'vertical' or self.orientation is None:
if self._need_to_set_index:
xticks = ax.get_xticks()
xticklabels = [get_label(x) for x in xticks]
ax.set_xticklabels(xticklabels)
ax.xaxis.set_major_locator(FixedLocator(xticks))
ax.xaxis.set_major_formatter(FixedFormatter(xticklabels))

self._apply_axis_properties(ax.xaxis, rot=self.rot,
fontsize=self.fontsize)
self._apply_axis_properties(ax.yaxis, fontsize=self.fontsize)
Expand All @@ -426,12 +412,6 @@ def get_label(i):
fontsize=self.fontsize)

elif self.orientation == 'horizontal':
if self._need_to_set_index:
yticks = ax.get_yticks()
yticklabels = [get_label(y) for y in yticks]
ax.set_yticklabels(yticklabels)
ax.xaxis.set_major_locator(FixedLocator(yticks))
ax.xaxis.set_major_formatter(FixedFormatter(yticklabels))
self._apply_axis_properties(ax.yaxis, rot=self.rot,
fontsize=self.fontsize)
self._apply_axis_properties(ax.xaxis, fontsize=self.fontsize)
Expand Down Expand Up @@ -1115,6 +1095,20 @@ def _update_stacker(cls, ax, stacking_id, values):
ax._stacker_neg_prior[stacking_id] += values

def _post_plot_logic(self, ax, data):
from matplotlib.ticker import FixedLocator

def get_label(i):
try:
return pprint_thing(data.index[i])
except Exception:
return ''

if self._need_to_set_index:
xticks = ax.get_xticks()
xticklabels = [get_label(x) for x in xticks]
ax.set_xticklabels(xticklabels)
ax.xaxis.set_major_locator(FixedLocator(xticks))

condition = (not self._use_dynamic_x() and
data.index.is_all_dates and
not self.subplots or
Expand Down