import numpy as np import holoviews as hv hv.extension('bokeh', 'matplotlib') %opts Points [size_index=None] (size=8) Scatter (size=5) Image (cmap='Reds') %opts Bounds (line_width=2 color='black') {+axiswise} Text (fontsize='16pt') np.random.seed(42) edges, data = np.histogram(np.random.randn(100)) hist = hv.Histogram(edges, data) subregion = hist[0:1] hist * subregion hist[0.25], hist[0.5], hist[0.55] xs = np.linspace(0, np.pi*2, 21) curve = hv.Curve((xs, np.sin(xs))) subregion = curve[np.pi/2:np.pi*1.5] curve * subregion * hv.Scatter(curve) curve[4.05], curve[4.1], curve[4.17], curve[4.3] curve[4:4.5] r = np.arange(0, 1, 0.005) xs, ys = (r * fn(85*np.pi*r) for fn in (np.cos, np.sin)) paths = hv.Points((xs, ys)) paths + paths[0:1, 0:1] %%output backend='matplotlib' xs = np.linspace(0, np.pi*8, 201) scatter = hv.Scatter3D((xs, np.sin(xs), np.cos(xs))) scatter + scatter[5:10, :, 0:] %opts Image (cmap='Blues') Bounds (color='red') np.random.seed(0) extents = (0, 0, 10, 10) img = hv.Image(np.random.rand(10, 10), bounds=extents) img_slice = img[1:9,4:5] box = hv.Bounds((1,4,9,5)) img*box + img_slice img[4.2,4.2], img[4.3,4.2], img[5.0,4.2] xs = np.linspace(0, np.pi*2, 21) curve = hv.Curve((xs, np.sin(xs))) print('x: %s, y: %s' % (curve.iloc[8, 0], curve.iloc[8, 1])) curve * hv.Scatter(curve.iloc[8]) curve + curve.iloc[5:16:2] curve.iloc[[0, 5, 10, 15, 20]] + curve.iloc[xs>3] img_coords = hv.Points(img.table(), extents=extents) labeled_img = img * img_coords * hv.Points([img.closest([(4.1,4.3)])]).options(color='r') img + labeled_img + img.sample([(4.1,4.3)]) img[4.1,4.3] sampled = img.sample(y=5) labeled_img = img * img_coords * hv.Points(zip(sampled['x'], [img.closest(y=5)]*10)) img + labeled_img + sampled xs = np.arange(10) samples = [2, 4, 6, 8] curve = hv.Curve(zip(xs, np.sin(xs))) curve_samples = hv.Scatter(zip(xs, [0] * 10)) * hv.Scatter(zip(samples, [0]*len(samples))) curve + curve_samples + curve.sample(samples) obs_hmap = hv.HoloMap({i: hv.Image(np.random.randn(10, 10), bounds=extents) for i in range(3)}, kdims='Observation') %%output backend='matplotlib' size=120 sample_style = dict(edgecolors='k', alpha=1) all_samples = obs_hmap.table().to.scatter3d().options(alpha=0.15, xticks=4) sampled = obs_hmap.sample((3,3)) subsamples = sampled.to.scatter3d().options(**sample_style) all_samples * subsamples + sampled %%output backend='matplotlib' size=120 sampled = obs_hmap.sample((3,3), bounds=(2,5,5,10)) subsamples = sampled.to.scatter3d().options(**dict(sample_style, xticks=4)) all_samples * subsamples + sampled xs = np.arange(10) extents = (0, 0, 2, 10) curve = hv.HoloMap({(i) : hv.Curve(zip(xs, np.sin(xs)*i)) for i in np.linspace(0.5, 1.5, 3)}, kdims='Observation') all_samples = curve.table().to.points() sampled = curve.sample([0, 2, 4, 6, 8]) sampling = all_samples * sampled.to.points(extents=extents).options(color='r') sampling + sampled sampled = curve.table().select(Observation=(0, 1.1), x={0, 2, 4, 6, 8}) sampling = all_samples * sampled.to.points(extents=extents).options(color='r') sampling + sampled