facebook/prophet

Should not call `fig.tight_layout()` unconditionally

已關閉

#2,257 建立於 2022年9月1日

 (5 則留言) (0 個反應) (0 位負責人)Python (4,451 個分叉)batch import
enhancementgood first issue

倉庫指標

星標
 (17,686 顆星)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

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)

貢獻者指南