magland / sortingview

Web app for viewing results of ephys spike sorting
Apache License 2.0
25 stars 8 forks source link

implement TimeseriesGraph replacement to PositionPlot #208

Closed magland closed 2 years ago

magland commented 2 years ago

See this script

https://github.com/magland/sortingview/blob/main/examples/example_timeseries_graph.py

which generates this example

https://www.figurl.org/f?v=gs://figurl/spikesortingview-9&d=sha1://e5683f7e0ac5cb6958e62ea37099c1ba8af4ce51&label=Timeseries%20graph%20example

As is, you can generate an arbitrary number of series, each one is either a line or marker, and you can specify the color.

The syntax might be considered a bit cumbersome, but it is designed to be extendable and efficient, and is based on the vega-lite spec, which altair uses.

magland commented 2 years ago

Example usage:

t = ... # 1-d array of times
y1 = ... # 1-d array of values
y2 = ... # 1-d array of values

G = vv.TimeseriesGraph()
G.add_line_series(name='1', t=t, y=y1, color='blue')
G.add_marker_series(name='2', t=t, y=y2, color='green')
url = G.url(label='...')
print(url)