Skip to content

Commit 560c9a8

Browse files
committed
Fix 28021: Add 5% padding in timeseries line plot
1 parent 60c4ce6 commit 560c9a8

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

pandas/plotting/_matplotlib/core.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1560,11 +1560,10 @@ def _make_plot(self, fig: Figure) -> None:
15601560
self._append_legend_handles_labels(newlines[0], label)
15611561

15621562
if self._is_ts_plot():
1563-
# reset of xlim should be used for ts data
1564-
# TODO: GH28021, should find a way to change view limit on xaxis
15651563
lines = get_all_lines(ax)
15661564
left, right = get_xlim(lines)
1567-
ax.set_xlim(left, right)
1565+
padding = (right - left) * 0.05
1566+
ax.set_xlim(left - padding, right + padding)
15681567

15691568
# error: Signature of "_plot" incompatible with supertype "MPLPlot"
15701569
@classmethod

0 commit comments

Comments
 (0)