Skip to content

Instantly share code, notes, and snippets.

@ericmjl
Created August 31, 2018 18:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericmjl/5fd39a3767f2e21bc45b18c031dc65e2 to your computer and use it in GitHub Desktop.
Save ericmjl/5fd39a3767f2e21bc45b18c031dc65e2 to your computer and use it in GitHub Desktop.
Holoviews dynamic map with datashader
import datashader as ds
import holoviews as hv
from holoviews.operation.datashader import datashade
hv.extension('bokeh')
def scatter(dim1, dim2):
def _scatter(data):
return hv.Scatter(data, kdims=[dim1], vdims=[dim2], extents=(-10, -10, 10, 10))
return _scatter
pipe = hv.streams.Pipe()
dmap = hv.DynamicMap(scatter('x', 'y'), streams=[pipe])
datashade(dmap)
import numpy as np
n = 100000
for i in np.arange(-np.pi, np.pi, 0.1):
x = np.random.normal(loc=0, scale=1, size=n)
y = i * x + np.random.normal(loc=0, scale=1, size=n)
pipe.send({'x': x, 'y': y})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment