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:
There has been some inital work in #23839, but the topic is not completely solved.
Proposed fix
We need to define what clear means.
First on an abstract level: This could be a starting point:
- All data-like content should be removed (actual data, labels, etc.)
- Scales and limits should be reset
- 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?
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:
There has been some inital work in #23839, but the topic is not completely solved.
Proposed fix
We need to define what
clearmeans.First on an abstract level: This could be a starting point:
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?