mirror of
https://github.com/kernc/backtesting.py.git
synced 2024-01-28 15:29:30 +03:00
ENH: Make plot span 100% of browser width by default
This commit is contained in:
@@ -69,7 +69,7 @@ def lightness(color, lightness=.94):
|
||||
return color.to_rgb()
|
||||
|
||||
|
||||
def plot(*, results, df, indicators, filename='', plot_width=1200,
|
||||
def plot(*, results, df, indicators, filename='', plot_width=None,
|
||||
plot_equity=True, plot_pl=True,
|
||||
plot_volume=True, plot_drawdown=False,
|
||||
smooth_equity=False, relative_equity=True, omit_missing=True,
|
||||
@@ -550,13 +550,17 @@ return this.labels[index] || "";
|
||||
wheelzoom_tool = next(wz for wz in f.tools if isinstance(wz, WheelZoomTool))
|
||||
wheelzoom_tool.maintain_focus = False
|
||||
|
||||
kwargs = {}
|
||||
if plot_width is None:
|
||||
kwargs['sizing_mode'] = 'stretch_width'
|
||||
|
||||
fig = gridplot(
|
||||
plots,
|
||||
ncols=1,
|
||||
toolbar_location='right',
|
||||
# sizing_mode='stretch_width',
|
||||
toolbar_options=dict(logo=None),
|
||||
merge_tools=True,
|
||||
**kwargs
|
||||
)
|
||||
show(fig, browser=None if open_browser else 'none')
|
||||
return fig
|
||||
|
||||
@@ -934,7 +934,7 @@ class Backtest:
|
||||
s._trade_data = df # Private API
|
||||
return s
|
||||
|
||||
def plot(self, *, results: pd.Series = None, filename=None, plot_width=1200,
|
||||
def plot(self, *, results: pd.Series = None, filename=None, plot_width=None,
|
||||
plot_equity=True, plot_pl=True,
|
||||
plot_volume=True, plot_drawdown=False,
|
||||
smooth_equity=False, relative_equity=True,
|
||||
@@ -953,11 +953,10 @@ class Backtest:
|
||||
By default, a strategy/parameter-dependent file is created in the
|
||||
current working directory.
|
||||
|
||||
`plot_width` is the width of the plot in pixels. The height is
|
||||
`plot_width` is the width of the plot in pixels. If None (default),
|
||||
the plot is made to span 100% of browser width. The height is
|
||||
currently non-adjustable.
|
||||
|
||||
.. TODO:: Make Bokeh plot span 100% browser width by default.
|
||||
|
||||
If `plot_equity` is `True`, the resulting plot will contain
|
||||
an equity (cash plus assets) graph section.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user