Say that I created a Figure with
from matplotlib import pyplot as plt
fig = plt.figure()
and then AFTER I created I want to change its layout (I am aware that I can instantiate the Figure object by passing the argument layout to plt.figure, e.g. fig = plt.figure(layout="constrained")
, which is not what I want).
So far, I know that one could do
fig.tight_layout()
to set a tight layout, but what if one to set a "constrained" layout?
Furthermore, other than "tight" and "constrained" what are the other possible available layouts?
CodePudding user response:
You can use the fig.set_layout_engine()
with matplolib-3.6.2
:
As follows:
fig = plt.figure()
fig.set_layout_engine('constrained')
The possible layouts as per documentation are: 'constrained', 'compressed', 'tight'
.