Description
Summary
Split out of #24617. Before we can implement this, we need a though API discussion (#24617 (comment)).
Current state:
- The kwarg
figsize
is IMHO well named and extremly widely used. It must stay as is. - The methods
set/get_size_inches()
as also widely used (90k matches on GitHub) and thus cannot be changed
We have to make a tradeoff decsion here: What is worse the naming inconsisteny (1) or multiple functions doing the same thing (2)?
I'm ok with going with (2), under the condition that set_figsize()
and set_size_inches()
as not equal aliases. There should be a clear guidance what to use. In practice that means discouraging set_size_inches
in favor of set_figsize()
.
There's a separate discussion whether set_figsize()
should accept both two individual parameters as well as one tuple. The tuple is mainly to make fig.set(figsize=(w, h))
work because that single tuple is forwarded to set_figsize
, but we could also create API infrastructure that specifies on the setter how multipe parameters can be handled in a set() call, i.e. there would be an internal preprocessing that unpacks the tuple for the set_figsize
call.
Side-note: I've recently created #29612 to (partially) address the long-standing and much asked-for figure unit topic. One could expand that to set_figsize()
later.
Discarded: When moving API anyway, one could consider going with size
instead of figsize
. That's shorter and fig.set_size()
/ plt.figure(size=...)
would work well. However, it would be an even larger API break, and we cannot use that for plt.subplots(..., size=...)
, because that would be too ambigous. Therefore subplots(..., figsize=...)
must be kept. While we strictly don't need to have naming equivalence between subplots()
and figure
concerning this parameter, overall it's not worth it, so let's stick to figsize
everywhere.