Skip to content

Commit

Permalink
Merge 835510c into be5c269
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Aug 19, 2019
2 parents be5c269 + 835510c commit e71b0be
Show file tree
Hide file tree
Showing 3 changed files with 394 additions and 129 deletions.
29 changes: 21 additions & 8 deletions examples/user_guide/15-Large_Data.ipynb
Expand Up @@ -194,7 +194,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"![](http://assets.holoviews.org/gifs/guides/user_guide/Large_Data/rasterize_color_range.gif)"
"<img src=\"http://assets.holoviews.org/gifs/guides/user_guide/Large_Data/rasterize_color_range.gif\"></img>"
]
},
{
Expand Down Expand Up @@ -363,7 +363,13 @@
"\n",
"# Hover info\n",
"\n",
"As you can see in the examples above, converting the data to an image using Datashader makes it feasible to work with even very large datasets interactively. One unfortunate side effect is that the original datapoints and line segments can no longer be used to support \"tooltips\" or \"hover\" information directly for RGB images generated with `datashade`; that data simply is not present at the browser level, and so the browser cannot unambiguously report information about any specific datapoint. Luckily, you can still provide hover information that reports properties of a subset of the data in a separate layer (as above), or you can provide information for a spatial region of the plot rather than for specific datapoints. For instance, in some small rectangle you can provide statistics such as the mean, count, standard deviation, etc:"
"As you can see in the examples above, converting the data to an image using Datashader makes it feasible to work with even very large datasets interactively. One unfortunate side effect is that the original datapoints and line segments can no longer be used to support \"tooltips\" or \"hover\" information directly for RGB images generated with `datashade`; that data simply is not present at the browser level, and so the browser cannot unambiguously report information about any specific datapoint. \n",
"\n",
"Additionally once the ``shade`` operation is applied any detail about the underlying data is obscured. In order to get hover information there are therefore two options:\n",
"\n",
"1) Use the ``rasterize`` operation without `shade`\n",
"\n",
"2) Overlay a separate layer as a ``QuadMesh`` or ``Image`` containing the hover information"
]
},
{
Expand All @@ -374,20 +380,24 @@
"source": [
"from holoviews.streams import RangeXY\n",
"\n",
"rasterized = rasterize(points, width=400, height=400)\n",
"\n",
"fixed_hover = (datashade(points, width=400, height=400) * \n",
" hv.QuadMesh(rasterize(points, width=10, height=10, dynamic=False)))\n",
"\n",
"dynamic_hover = (datashade(points, width=400, height=400) * \n",
" hv.util.Dynamic(rasterize(points, width=10, height=10, streams=[RangeXY]), operation=hv.QuadMesh))\n",
" rasterize(points, width=10, height=10, streams=[RangeXY]).apply(hv.QuadMesh))\n",
"\n",
"(fixed_hover + dynamic_hover).opts(opts.QuadMesh(tools=['hover'], alpha=0, hover_alpha=0.2))"
"(rasterized + fixed_hover + dynamic_hover).opts(\n",
" opts.QuadMesh(tools=['hover'], alpha=0, hover_alpha=0.2), \n",
" opts.Image(tools=['hover']))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In the above examples, the plot on the left provides hover information at a fixed spatial scale, while the one on the right reports on an area that scales with the zoom level so that arbitrarily small regions of data space can be examined, which is generally more useful (but requires a live Python server). Note that you can activate the hover tool for `Image` elements output by the `rasterize` operation."
"In the above examples, the plot on the left provides hover information directly on the aggregated ``Image``. The middle plot displays hover information as a ``QuadMesh`` at a fixed spatial scale, while the one on the right reports on an area that scales with the zoom level so that arbitrarily small regions of data space can be examined, which is generally more useful (but requires a live Python server)."
]
},
{
Expand Down Expand Up @@ -444,7 +454,7 @@
"opts.defaults(\n",
" opts.Image(aspect=1, axiswise=True, xaxis='bare', yaxis='bare'),\n",
" opts.RGB(aspect=1, axiswise=True, xaxis='bare', yaxis='bare'),\n",
" opts.Layout(vspace=0.1, hspace=0.1, sublabel_format=\"\"))\n",
" opts.Layout(vspace=0.1, hspace=0.1, sublabel_format=\"\", fig_size=80))\n",
"\n",
"np.random.seed(12)\n",
"N=100\n",
Expand All @@ -464,6 +474,9 @@
"\n",
"shadeable = [elemtype(pts) for elemtype in [hv.Curve, hv.Scatter, hv.Points]]\n",
"shadeable += [hv.Path([pts])]\n",
"shadeable += [hv.Spikes(np.random.randn(10000))]\n",
"shadeable += [hv.Area(np.random.randn(10000).cumsum())]\n",
"shadeable += [hv.Spread((np.arange(10000), np.random.randn(10000).cumsum(), np.random.randn(10000)*10))]\n",
"shadeable += [hv.Image((x,y,z)), hv.QuadMesh((x,y,z))]\n",
"shadeable += [hv.Graph(((np.zeros(N), np.arange(N)),))]\n",
"shadeable += [tri.edgepaths]\n",
Expand Down Expand Up @@ -491,8 +504,8 @@
"metadata": {},
"outputs": [],
"source": [
"rgb_opts = opts.RGB(aspect=1, axiswise=True, xaxis='bare', yaxis='bare')\n",
"hv.Layout([e.relabel(e.__class__.name).opts(rgb_opts) for e in shadeable + rasterizable]).cols(6)"
"el_opts = dict(aspect=1, axiswise=True, xaxis='bare', yaxis='bare')\n",
"hv.Layout([e.relabel(e.__class__.name).opts(**el_opts) for e in shadeable + rasterizable]).cols(6)"
]
},
{
Expand Down

0 comments on commit e71b0be

Please sign in to comment.