FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix standalone+time-based scatter plots · robot-python/finplot@cfd2dd6 · GitHub

Commit cfd2dd6

Browse files
committed
Fix standalone+time-based scatter plots
1 parent 0a3a19a commit cfd2dd6

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎finplot/__init__.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1493,7 +1493,7 @@ def plot(x, y=None, color=None, width=1, ax=None, style=None, legend=None, zooms
14931493
_set_datasrc(ax, datasrc)
14941494
if legend is not None:
14951495
_create_legend(ax)
1496-
x = datasrc.x if datasrc.standalone or not ax.vb.x_indexed else datasrc.index
1496+
x = datasrc.x if not ax.vb.x_indexed else datasrc.index
14971497
y = datasrc.y / ax.vb.yscale.scalef
14981498
if style is None or any(ch in style for ch in '-_.'):
14991499
connect_dots = 'finite' # same as matplotlib; use datasrc.standalone=True if you want to keep separate intervals on a plot
@@ -2062,6 +2062,11 @@ def _set_datasrc(ax, datasrc, addcols=True):
20622062
else:
20632063
viewbox.standalones.add(datasrc)
20642064
datasrc.update_init_x(viewbox.init_steps)
2065+
if datasrc.timebased() and viewbox.datasrc is not None:
2066+
## print('WARNING: re-indexing standalone, time-based plot')
2067+
vdf = viewbox.datasrc.df
2068+
d = {v:k for k,v in enumerate(vdf[vdf.columns[0]])}
2069+
datasrc.df.index = [d[i] for i in datasrc.df[datasrc.df.columns[0]]]
20652070
## if not viewbox.x_indexed:
20662071
## _set_x_limits(ax, datasrc)
20672072
# update period if this datasrc has higher time resolution

‎finplot/examples/complicated.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ def change_asset(*args, **kwargs):
259259

260260
symbol = ctrl_panel.symbol.currentText()
261261
interval = ctrl_panel.interval.currentText()
262+
ws.close()
262263
ws.df = None
263264
df = load_price_history(symbol, interval=interval)
264265
ws.reconnect(symbol, interval, df)

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL