Skip to content

Commit 102f5a9

Browse files
committed
Refactor handling of x_data in matplotlib plotting.
Simplify and streamline the code by directly assigning x_data from the data variable and replacing the intermediate Series object with a clearer `s` variable. This improves readability and maintains the existing functionality.
1 parent 0d0375a commit 102f5a9

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

pandas/plotting/_matplotlib/core.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,11 +1343,12 @@ def _make_plot(self, fig: Figure) -> None:
13431343
x, y, c, data = self.x, self.y, self.c, self.data
13441344
ax = self.axes[0]
13451345

1346-
x_data = Series(index=data[x])
1347-
if use_dynamic_x(ax, x_data.index):
1348-
x_data = maybe_convert_index(ax, x_data)
1349-
freq, x_data = prepare_ts_data(x_data, ax, self.kwds)
1350-
x_data = x_data.index
1346+
x_data = data[x]
1347+
s = Series(index=x_data)
1348+
if use_dynamic_x(ax, s.index):
1349+
s = maybe_convert_index(ax, s)
1350+
freq, s = prepare_ts_data(s, ax, self.kwds)
1351+
x_data = s.index
13511352

13521353
c_is_column = is_hashable(c) and c in self.data.columns
13531354

0 commit comments

Comments
 (0)