Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Summary
Axes.clear()
/Axes.cla()
are only documented as "Clear the Axes". What exactly "clear" means is neither documented nor well defined. We reset some stuff and keep other.
This leads to a number of issues:
- Axes.cla() resets axis label position of twin axes[Bug]: Axes.cla() resets axis label position of twin axes #28846 and associated PRFixed xlim issue when clearing shared axes #28101
- y_label in wrong place after clearing for twinx axes[Bug]: y_label in wrong place after clearing for twinx axes #28268 (and duplicate[Bug]: Axes.cla() resets axis label position of twin axes #28846)
- Axes.cla() with sharex may wrongly reset the axes limit.[Bug]: Axes.cla() with sharex may wrongly reset the axes limit. #27825
- Axes.clear does not reset axislabel or ticklabel sizes[Bug]: Axes.clear does not reset axislabel or ticklabel sizes #21239
There has been some inital work in#23839, but the topic is not completely solved.
Proposed fix
We need to define whatclear
means.
First on an abstract level: This could be a starting point:
- All data-like content should be removed (actual data, labels, etc.)
- Layout should stay (axes position, twinning)
- Formatting: t.b.d.
When the high-level definition is agreed upon, we need to define what that means for concrete cases.
e.g. it's clear that we remove label content. Should label positions also be reset (e.g. if somebody has moved the xlabel to top)? - This may also depend on the anticipated use case: One wants to reuse the Axes for a new plot. How similar is it to the old plot. Does it only get new data and labels or could it be a completely different plot?