Skip to content

Commit

Permalink
Merge 4719abe into 4f52bb6
Browse files Browse the repository at this point in the history
  • Loading branch information
jlstevens committed Dec 10, 2018
2 parents 4f52bb6 + 4719abe commit 1eb0366
Show file tree
Hide file tree
Showing 39 changed files with 310 additions and 167 deletions.
2 changes: 1 addition & 1 deletion examples/reference/containers/bokeh/GridSpace.ipynb
Expand Up @@ -99,7 +99,7 @@
"metadata": {},
"outputs": [],
"source": [
"%%output size=50\n",
"hv.output(size=50)\n",
"hmap = hv.HoloMap(gridspace)\n",
"hmap + hv.GridSpace(hmap)"
]
Expand Down
5 changes: 3 additions & 2 deletions examples/reference/elements/bokeh/Arrow.ipynb
Expand Up @@ -21,6 +21,7 @@
"source": [
"import numpy as np\n",
"import holoviews as hv\n",
"from holoviews import opts\n",
"hv.extension('bokeh')"
]
},
Expand All @@ -37,10 +38,10 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Curve (color='#D3D3D3')\n",
"xs = np.linspace(-5,5,100)\n",
"ys = -(xs-2)**3\n",
"hv.Curve((xs,ys)) * hv.Arrow(0,10, 'Inflection', 'v')"
"curve = hv.Curve((xs,ys)).opts(color='#D3D3D3')\n",
"curve * hv.Arrow(0,10, 'Inflection', 'v')"
]
},
{
Expand Down
5 changes: 3 additions & 2 deletions examples/reference/elements/bokeh/Bars.ipynb
Expand Up @@ -21,6 +21,7 @@
"source": [
"import numpy as np\n",
"import holoviews as hv\n",
"from holoviews import opts\n",
"hv.extension('bokeh')"
]
},
Expand Down Expand Up @@ -73,14 +74,14 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Bars.Stacked [stacked=True]\n",
"from itertools import product\n",
"np.random.seed(3)\n",
"index, groups = ['A', 'B'], ['a', 'b']\n",
"keys = product(index, groups)\n",
"bars = hv.Bars([k+(np.random.rand()*100.,) for k in keys],\n",
" ['Index', 'Group'], 'Count')\n",
"bars.relabel(group='Grouped') + bars.relabel(group='Stacked')"
"stacked = bars.opts(stacked=True, clone=True)\n",
"bars.relabel(group='Grouped') + stacked.relabel(group='Stacked')"
]
},
{
Expand Down
10 changes: 5 additions & 5 deletions examples/reference/elements/bokeh/Bivariate.ipynb
Expand Up @@ -21,6 +21,7 @@
"source": [
"import numpy as np\n",
"import holoviews as hv\n",
"from holoviews import opts\n",
"hv.extension('bokeh')"
]
},
Expand Down Expand Up @@ -58,8 +59,8 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Bivariate [filled=True colorbar=True width=350 toolbar='above'] (cmap='Blues')\n",
"hv.Bivariate(normal)"
"hv.Bivariate(normal).opts(\n",
" opts.Bivariate(cmap='Blues', colorbar=True, filled=True, toolbar='above', width=350))"
]
},
{
Expand All @@ -75,9 +76,8 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Bivariate {+axiswise}\n",
"hv.NdLayout({bw: hv.Bivariate(normal).options(bandwidth=bw)\n",
" for bw in [0.05, 0.1, 0.5, 1]}, 'Bandwidth').cols(2)"
"hv.NdLayout({bw: hv.Bivariate(normal).opts(bandwidth=bw, axiswise=True)\n",
" for bw in [0.05, 0.1, 0.5, 1]}, 'Bandwidth').cols(2)"
]
},
{
Expand Down
5 changes: 3 additions & 2 deletions examples/reference/elements/bokeh/Bounds.ipynb
Expand Up @@ -20,6 +20,7 @@
"outputs": [],
"source": [
"import holoviews as hv\n",
"from holoviews import opts\n",
"hv.extension('bokeh')"
]
},
Expand All @@ -36,9 +37,9 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Bounds (color='orange' line_width=6)\n",
"penguins = hv.RGB.load_image('../assets/penguins.png')\n",
"penguins * hv.Bounds((-0.15, -0.4, 0.2, 0))"
"(penguins * hv.Bounds((-0.15, -0.4, 0.2, 0))).opts(\n",
" opts.Bounds(color='orange', line_width=6))"
]
},
{
Expand Down
13 changes: 9 additions & 4 deletions examples/reference/elements/bokeh/Box.ipynb
Expand Up @@ -21,6 +21,7 @@
"source": [
"import numpy as np\n",
"import holoviews as hv\n",
"from holoviews import opts\n",
"hv.extension('bokeh')"
]
},
Expand All @@ -37,11 +38,13 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Box (line_width=5 color='red') Image (cmap='gray')\n",
"data = np.sin(np.mgrid[0:100,0:100][1]/10.0)\n",
"data[np.arange(40, 60), np.arange(20, 40)] = -1\n",
"data[np.arange(40, 50), np.arange(70, 80)] = -3 \n",
"hv.Image(data) * hv.Box(-0.2, 0, 0.25 ) * hv.Box(-0, 0, (0.4,0.9) )"
"example = hv.Image(data) * hv.Box(-0.2, 0, 0.25 ) * hv.Box(-0, 0, (0.4,0.9) )\n",
"example.opts(\n",
" opts.Box(color='red', line_width=5), \n",
" opts.Image(cmap='gray'))"
]
},
{
Expand All @@ -59,10 +62,12 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Box (line_width=5 color='purple') Image (cmap='gray')\n",
"data = np.sin(np.mgrid[0:100,0:100][1]/10.0)\n",
"data[np.arange(30, 70), np.arange(30, 70)] = -3\n",
"hv.Image(data) * hv.Box(-0, 0, 0.25, aspect=3, orientation=-np.pi/4)"
"example = hv.Image(data) * hv.Box(-0, 0, 0.25, aspect=3, orientation=-np.pi/4)\n",
"example.opts(\n",
" opts.Box(color='purple', line_width=5), \n",
" opts.Image(cmap='gray'))"
]
},
{
Expand Down
8 changes: 5 additions & 3 deletions examples/reference/elements/bokeh/BoxWhisker.ipynb
Expand Up @@ -21,6 +21,7 @@
"source": [
"import numpy as np\n",
"import holoviews as hv\n",
"from holoviews import opts\n",
"hv.extension('bokeh')"
]
},
Expand Down Expand Up @@ -62,10 +63,11 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts BoxWhisker [width=600 height=400 show_legend=False] (whisker_color='gray' box_color='white')\n",
"groups = [chr(65+g) for g in np.random.randint(0, 3, 200)]\n",
"hv.BoxWhisker((groups, np.random.randint(0, 5, 200), np.random.randn(200)),\n",
" ['Group', 'Category'], 'Value').sort()"
"boxwhisker = hv.BoxWhisker((groups, np.random.randint(0, 5, 200), np.random.randn(200)),\n",
" ['Group', 'Category'], 'Value').sort()\n",
"boxwhisker.opts(\n",
" opts.BoxWhisker(box_color='white', height=400, show_legend=False, whisker_color='gray', width=600))"
]
},
{
Expand Down
7 changes: 5 additions & 2 deletions examples/reference/elements/bokeh/Chord.ipynb
Expand Up @@ -23,6 +23,7 @@
"source": [
"import pandas as pd\n",
"import holoviews as hv\n",
"from holoviews import opts, dim\n",
"from bokeh.sampledata.les_mis import data\n",
"\n",
"hv.extension('bokeh')\n",
Expand Down Expand Up @@ -98,8 +99,10 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Chord [labels='name'] (node_color=dim('index').astype(str) edge_color=dim('source').astype(str) cmap='Category20' edge_cmap='Category20')\n",
"hv.Chord((links, nodes)).select(value=(5, None))"
"chord = hv.Chord((links, nodes)).select(value=(5, None))\n",
"chord.opts(\n",
" opts.Chord(cmap='Category20', edge_cmap='Category20', edge_color=dim('source').str(), \n",
" labels='name', node_color=dim('index').str()))"
]
}
],
Expand Down
5 changes: 3 additions & 2 deletions examples/reference/elements/bokeh/Contours.ipynb
Expand Up @@ -21,6 +21,7 @@
"source": [
"import numpy as np\n",
"import holoviews as hv\n",
"from holoviews import opts\n",
"hv.extension('bokeh')"
]
},
Expand Down Expand Up @@ -60,10 +61,10 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Contours [colorbar=True width=325 tools=['hover']] (cmap='fire')\n",
"x,y = np.mgrid[-50:51, -50:51] * 0.05\n",
"img = hv.Image(np.sin(x**2+y**3))\n",
"img + hv.operation.contours(img, levels=5)"
"example = img + hv.operation.contours(img, levels=5)\n",
"example.opts(opts.Contours(cmap='fire', colorbar=True, tools=['hover'], width=325))"
]
},
{
Expand Down
7 changes: 4 additions & 3 deletions examples/reference/elements/bokeh/Curve.ipynb
Expand Up @@ -21,6 +21,7 @@
"source": [
"import numpy as np\n",
"import holoviews as hv\n",
"from holoviews import opts\n",
"hv.extension('bokeh')"
]
},
Expand Down Expand Up @@ -70,9 +71,9 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Curve [width=600] NdOverlay [legend_position='right']\n",
"hv.NdOverlay({interp: hv.Curve(points[::8]).options(interpolation=interp)\n",
" for interp in ['linear', 'steps-mid', 'steps-pre', 'steps-post']})"
"overlay =hv.NdOverlay({interp: hv.Curve(points[::8]).opts(interpolation=interp, width=600)\n",
" for interp in ['linear', 'steps-mid', 'steps-pre', 'steps-post']})\n",
"overlay.opts(legend_position='right')"
]
},
{
Expand Down
7 changes: 4 additions & 3 deletions examples/reference/elements/bokeh/Distribution.ipynb
Expand Up @@ -21,6 +21,7 @@
"source": [
"import numpy as np\n",
"import holoviews as hv\n",
"from holoviews import opts, Cycle\n",
"hv.extension('bokeh')"
]
},
Expand Down Expand Up @@ -59,8 +60,8 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Distribution [filled=False] (line_color=Cycle())\n",
"hv.NdOverlay({bw: hv.Distribution(normal).options(bandwidth=bw) for bw in [0.05, 0.1, 0.5, 1]})"
"overlay = hv.NdOverlay({bw: hv.Distribution(normal).opts(bandwidth=bw) for bw in [0.05, 0.1, 0.5, 1]})\n",
"overlay.opts(opts.Distribution(filled=False, line_color=Cycle()))"
]
},
{
Expand All @@ -82,7 +83,7 @@
"xdist, ydist = ((hv.Distribution(points2, kdims=[dim]) *\n",
" hv.Distribution(points, kdims=[dim])).redim.range(x=(-5, 5), y=(-5, 5))\n",
" for dim in 'xy')\n",
"(points2 * points) << ydist.options(width=125) << xdist.options(height=125)"
"(points2 * points) << ydist.opts(width=125) << xdist.opts(height=125)"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion examples/reference/elements/bokeh/Div.ipynb
Expand Up @@ -78,7 +78,7 @@
"df_html = img.dframe()[['z']].describe().to_html()\n",
"df_div = hv.Div(\"<div align='right'>\"+df_html+\"<div>\")\n",
"\n",
"img + surface_div + df_div.options(width=200)"
"img + surface_div + df_div.opts(width=200)"
]
}
],
Expand Down
12 changes: 10 additions & 2 deletions examples/reference/elements/bokeh/Ellipse.ipynb
Expand Up @@ -21,9 +21,19 @@
"source": [
"import numpy as np\n",
"import holoviews as hv\n",
"from holoviews import opts\n",
"hv.extension('bokeh')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"opts.defaults(opts.Ellipse(line_width=6))"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -37,7 +47,6 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Ellipse (line_width=6)\n",
"# Generate some data\n",
"c1 = np.random.normal(loc=2, scale=0.2, size=(200,200))\n",
"c2x = np.random.normal(loc=-2, scale=0.6, size=200)\n",
Expand All @@ -61,7 +70,6 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Ellipse (line_width=6)\n",
"clusters = hv.Points(c1) * hv.Points((c2x, c2y)) * hv.Points(c3)\n",
"clusters * hv.Ellipse(0,0, 4, orientation=np.pi/5, aspect=2) "
]
Expand Down
22 changes: 18 additions & 4 deletions examples/reference/elements/bokeh/Graph.ipynb
Expand Up @@ -21,10 +21,8 @@
"source": [
"import numpy as np\n",
"import holoviews as hv\n",
"\n",
"hv.extension('bokeh')\n",
"\n",
"%opts Graph [width=400 height=400 padding=0.1]"
"from holoviews import opts\n",
"hv.extension('bokeh')"
]
},
{
Expand All @@ -41,6 +39,22 @@
"\n",
"This reference document describes only basic functionality, for a more detailed summary on how to work with network graphs in HoloViews see the [User Guide](../../../user_guide/Network_Graphs.ipynb).\n",
"\n",
"To make the visualizations in this notebook easier to view, the first thing we will do is increase the default width and height:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"opts.defaults(opts.Graph(width=400, height=400))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### A simple Graph\n",
"\n",
"Let's start by declaring a very simple graph connecting one node to all others. If we simply supply the abstract connectivity of the ``Graph``, it will automatically compute a layout for the nodes using the ``layout_nodes`` operation, which defaults to a circular layout:"
Expand Down
7 changes: 5 additions & 2 deletions examples/reference/elements/bokeh/HLine.ipynb
Expand Up @@ -21,6 +21,7 @@
"source": [
"import numpy as np\n",
"import holoviews as hv\n",
"from holoviews import opts\n",
"hv.extension('bokeh')"
]
},
Expand All @@ -37,10 +38,12 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts HLine (color='blue' line_width=6) Points (color='#D3D3D3')\n",
"xs = np.random.normal(size=100)\n",
"ys = np.random.normal(size=100) * xs\n",
"hv.Points((xs,ys)) * hv.HLine(ys.mean())"
"overlay = hv.Points((xs,ys)) * hv.HLine(ys.mean())\n",
"overlay.opts(\n",
" opts.HLine(color='blue', line_width=6), \n",
" opts.Points(color='#D3D3D3'))"
]
},
{
Expand Down

0 comments on commit 1eb0366

Please sign in to comment.