prophet icon indicating copy to clipboard operation
prophet copied to clipboard

Should not call `fig.tight_layout()` unconditionally

Open davidgilbertson opened this issue 2 years ago • 5 comments

I'm calling plot() on a model and passing in an ax, which is then used to plot the function.

This ax exists in a figure that is using constrained layout, rather than tight layout.

The issue is that the Prophet plot function calls fig.tight_layout() on this line.

I think it should either:

  • Not do this if the user passes in an ax. In this case they're essentially saying "this is your canvas, draw onto this, please" and to reach up into the parent figure and change things is overstepping those bounds. OR
  • Check fig.get_tight_layout() before calling fig.tight_layout().

In fact, the internals of tight_layout()/subplots_adjust() does indeed check for the use of constrained layout and logs a warning, but this warning gets swallowed somewhere.

My workaround in the meantime is to just reset back to the rcParams values with:

m.plot(forecast, ax=ax).set_constrained_layout(None)

davidgilbertson avatar Sep 01 '22 01:09 davidgilbertson

@tcuongd i want to work on this issue

pranith7 avatar Nov 14 '22 09:11 pranith7

@pranith7 Did you make any progress on this issue? I would like to take a look.

adit299 avatar Jun 23 '23 15:06 adit299

Hi @tcuongd I created a PR addressing this issue. Would you please check that.

alhridoy avatar Oct 06 '23 18:10 alhridoy

nice thank you

sivapungamuru avatar Oct 20 '23 16:10 sivapungamuru

@tcuongd Would #2504 merged consider this closed? Thank you!

richardtorres314 avatar May 07 '24 02:05 richardtorres314