Skip to content

Commit

Permalink
Notebook improvements (#2220)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr authored and jlstevens committed Jan 3, 2018
1 parent b259243 commit fcdbca6
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 13 deletions.
36 changes: 27 additions & 9 deletions examples/user_guide/07-Tabular_Datasets.ipynb
Expand Up @@ -16,9 +16,29 @@
"By default HoloViews will use one of these data storage formats for tabular data:\n",
"\n",
"* A pure Python dictionary containing 1D NumPy-arrays for each column.\n",
"```\n",
"{'x': np.array([0, 1, 2]), 'y': np.array([0, 1, 2])}\n",
"```\n",
"* A purely NumPy array format for numeric data.\n",
"```\n",
"np.array([[0, 0], [1, 1], [2, 3]])\n",
"```\n",
"* Pandas DataFrames\n",
"* Dask DataFrames"
"```\n",
"pd.DataFrame(np.array([[0, 0], [1, 1], [2, 3]]), columns=['x', 'y'])\n",
"```\n",
"* Dask DataFrames\n",
"\n",
"A number of additonal standard constructors are supported:\n",
"\n",
"* A tuple of array (or array-like) objects\n",
"```\n",
"([0, 1, 2], [0, 1, 2])\n",
"```\n",
"* A list of tuples:\n",
"```\n",
"[(0, 0), (1, 1), (2, 2)]\n",
"```"
]
},
{
Expand All @@ -37,7 +57,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Simple Dataset"
"# A simple Dataset"
]
},
{
Expand Down Expand Up @@ -73,7 +93,7 @@
"metadata": {},
"outputs": [],
"source": [
"hv.Scatter(table) + hv.Curve(table) + hv.Bars(table)"
"(hv.Scatter(table) + hv.Curve(table) + hv.Area(table) + hv.Bars(table)).cols(2)"
]
},
{
Expand All @@ -84,12 +104,10 @@
"\n",
"As a guide to which Elements can be converted to each other, those of the same dimensionality here should be interchangeable, because of the underlying similarity of their columnar representation:\n",
"\n",
"* 0D: BoxWhisker, Spikes, Distribution*, \n",
"* 1D: Scatter, Curve, ErrorBars, Spread, Bars, BoxWhisker, Regression*\n",
"* 2D: Points, HeatMap, Bars, BoxWhisker, Bivariate*\n",
"* 3D: Scatter3D, TriSurface, VectorField, BoxWhisker, Bars\n",
"\n",
"\\* - requires Seaborn\n",
"* 0D: BoxWhisker, Spikes, Distribution\n",
"* 1D: Area, Bars, BoxWhisker, Curve, ErrorBars, Scatter, Spread\n",
"* 2D: Bars, Bivariate, BoxWhisker, HeatMap, Points, VectorField \n",
"* 3D: Scatter3D, TriSurface, VectorField\n",
"\n",
"This categorization is based only on the ``kdims``, which define the space in which the data has been sampled or defined. An Element can also have any number of value dimensions (``vdims``), which may be mapped onto various attributes of a plot such as the color, size, and orientation of the plotted items. For a reference of how to use these various Element types, see the [Elements Reference](http://holoviews.org/reference/index.html#elements)."
]
Expand Down
40 changes: 36 additions & 4 deletions examples/user_guide/Plotting_with_Bokeh.ipynb
Expand Up @@ -166,10 +166,10 @@
" ('None', {'yaxis': None}),\n",
" ('Rotate', {'xrotation': 90}),\n",
" ('N Ticks', {'xticks': 3}),\n",
" ('List Ticks', {'xticks': [0, 100, 300, 500]})]\n",
" ('List Ticks', {'xticks': [0, 20, 50, 90]})]\n",
"\n",
"hv.Layout([points.relabel(group=group).opts(plot=opts)\n",
" for group, opts in axes_opts]).cols(3).display('all')"
" for group, opts in axes_opts]).cols(3)"
]
},
{
Expand Down Expand Up @@ -244,15 +244,15 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Overlay [show_legend=False height=400 width=600] ErrorBars (line_width=5) Scatter(alpha=0.2 size=6)\n",
"%%opts Overlay [show_legend=False height=400 width=600] ErrorBars (line_width=5) Scatter [jitter=0.2] (alpha=0.2 size=6)\n",
"\n",
"overlay = hv.NdOverlay({group: hv.Scatter(([group]*100, np.random.randn(100)*(i+1)+i))\n",
" for i, group in enumerate(['A', 'B', 'C', 'D', 'E'])})\n",
"\n",
"errorbars = hv.ErrorBars([(k, el.reduce(function=np.mean), el.reduce(function=np.std))\n",
" for k, el in overlay.items()])\n",
"\n",
"global_mean = hv.Text('A', 12, 'Global mean: %.3f' % overlay.dimension_values('y').mean())\n",
"global_mean = hv.Text('A', 12, 'Global mean: %.3f' % overlay.dimension_values('y').mean(), halign='left')\n",
"\n",
"errorbars * overlay * hv.Curve(errorbars) * global_mean"
]
Expand Down Expand Up @@ -298,6 +298,38 @@
"Another reason to use ``tabs`` is that some Layout combinations may not be able to be displayed directly using HoloViews. For example, it is not currently possible to display a ``GridSpace`` as part of a ``Layout`` in any backend, and this combination will automatically switch to a ``tab`` representation for the bokeh backend."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Interactive Legends\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"When using ``NdOverlay`` and ``Overlay`` containers each element will get a legend entry, which can be used to interactively toggle the visibility of the element. In this example we will create a number of ``Histogram`` elements each with a different mean. By setting a ``muted_fill_alpha`` we can define the style of the element when it is de-selected using the legend, simply try tapping on each legend entry to see the effect:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%opts Histogram [width=600] (alpha=0.8 muted_fill_alpha=0.1)\n",
"hv.NdOverlay({i: hv.Histogram(np.histogram(np.random.randn(100)+i*2)) for i in range(5)})"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The other ``muted_`` options can be used to define other aspects of the Histogram style when it is unselected."
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down

0 comments on commit fcdbca6

Please sign in to comment.