From 6c73c76bee65103781e77860640dc0074931b8b1 Mon Sep 17 00:00:00 2001 From: Daniel Alfonsetti Date: Sat, 17 Feb 2024 20:28:20 -0500 Subject: [PATCH 1/2] Optional plot show feature --- backtrader/cerebro.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/backtrader/cerebro.py b/backtrader/cerebro.py index 9b18e7775..2bcfb2e9e 100644 --- a/backtrader/cerebro.py +++ b/backtrader/cerebro.py @@ -938,8 +938,12 @@ def getbroker(self): broker = property(getbroker, setbroker) + def get_figures(self, **kwargs): + + return self.plot(show_plots=False, **kwargs) + def plot(self, plotter=None, numfigs=1, iplot=True, start=None, end=None, - width=16, height=9, dpi=300, tight=True, use=None, + width=16, height=9, dpi=300, tight=True, use=None, show_plots=True, **kwargs): ''' Plots the strategies inside cerebro @@ -998,7 +1002,8 @@ def plot(self, plotter=None, numfigs=1, iplot=True, start=None, end=None, figs.append(rfig) - plotter.show() + if show_plots: + plotter.show() return figs From 1f2b627443d9b0fbeb5bea7ba33c5652375e6544 Mon Sep 17 00:00:00 2001 From: Daniel Alfonsetti Date: Sat, 24 Feb 2024 15:52:07 -0500 Subject: [PATCH 2/2] Plots --- backtrader/cerebro.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backtrader/cerebro.py b/backtrader/cerebro.py index 2bcfb2e9e..9a87d6f15 100644 --- a/backtrader/cerebro.py +++ b/backtrader/cerebro.py @@ -938,9 +938,12 @@ def getbroker(self): broker = property(getbroker, setbroker) - def get_figures(self, **kwargs): + def get_figures(self, plotter=None, numfigs=1, iplot=True, start=None, end=None, + width=16, height=9, dpi=300, tight=True, use=None, **kwargs): - return self.plot(show_plots=False, **kwargs) + return self.plot(plotter=None, numfigs=1, iplot=True, start=None, end=None, + width=16, height=9, dpi=300, tight=True, use=None, show_plots=False, + **kwargs) def plot(self, plotter=None, numfigs=1, iplot=True, start=None, end=None, width=16, height=9, dpi=300, tight=True, use=None, show_plots=True,