ENH: Make plot span 100% of browser width by default

This commit is contained in:
Kernc
2019-09-23 03:56:21 +02:00
parent a43ced9504
commit 5bcaafd6b3
3 changed files with 10 additions and 7 deletions

View File

@@ -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

View File

@@ -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.

View File

@@ -33,7 +33,7 @@ if __name__ == '__main__':
'typing ; python_version < "3.5"',
'numpy',
'pandas >= 0.21.0, != 0.25.0',
'bokeh >= 0.12.15',
'bokeh >= 1.1.0',
],
extras_require={
'doc': [