Skip to content

Commit

Permalink
Further updates to plotly reference notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Dec 11, 2018
1 parent 7776578 commit 71a64f2
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 24 deletions.
4 changes: 3 additions & 1 deletion examples/reference/elements/plotly/Area.ipynb
Expand Up @@ -94,7 +94,9 @@
"values = np.random.rand(5, 20)\n",
"percentages = (values/values.sum(axis=0)).T*100\n",
"\n",
"overlay = hv.Overlay([hv.Area(percentages[:, i], vdims=[hv.Dimension('value', unit='%')]) for i in range(5)])\n",
"value_dim = hv.Dimension('value', unit='%')\n",
"\n",
"overlay = hv.Overlay([hv.Area(percentages[:, i], vdims=value_dim) for i in range(5)])\n",
"overlay + hv.Area.stack(overlay)"
]
},
Expand Down
2 changes: 1 addition & 1 deletion examples/reference/elements/plotly/BoxWhiskers.ipynb
Expand Up @@ -67,7 +67,7 @@
"box = hv.BoxWhisker((groups, np.random.randint(0, 5, 200), np.random.randn(200)),\n",
" ['Group', 'Category'], 'Value').sort()\n",
"\n",
"box.opts(height=400, show_legend=False, width=600)"
"box.opts(height=400, width=600)"
]
},
{
Expand Down
3 changes: 2 additions & 1 deletion examples/reference/elements/plotly/HeatMap.ipynb
Expand Up @@ -57,7 +57,8 @@
"outputs": [],
"source": [
"heatmap = hv.HeatMap([(0, 0, 0), (0, 0, 10), (1, 0, 2), (1, 1, 3)])\n",
"heatmap + heatmap.aggregate(function=np.max).opts(colorbar=True)"
"aggregate = heatmap.aggregate(function=np.max)\n",
"heatmap + aggregate.opts(colorbar=True)"
]
},
{
Expand Down
3 changes: 2 additions & 1 deletion examples/reference/elements/plotly/Image.ipynb
Expand Up @@ -75,8 +75,9 @@
"outputs": [],
"source": [
"closest = img.closest((0.1,0.1))\n",
"points = hv.Points([closest])\n",
"print('The value at position %s is %s' % (closest, img[0.1, 0.1]))\n",
"img * hv.Points([img.closest((0.1,0.1))]).opts(color='black', marker='cross')"
"img * points.opts(color='black', marker='cross', size=10)"
]
},
{
Expand Down
11 changes: 6 additions & 5 deletions examples/reference/elements/plotly/Points.ipynb
Expand Up @@ -30,7 +30,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The ``Points`` element visualizes as markers placed in a space of two independent variables, traditionally denoted *x* and *y*. In HoloViews, the names ``'x'`` and ``'y'`` are used as the default ``key_dimensions`` of the element. We can see this from the default axis labels when visualizing a simple ``Points`` element:"
"The ``Points`` element visualizes as markers placed in a space of two independent variables, traditionally denoted ``x`` and ``y``. In HoloViews, the names ``'x'`` and ``'y'`` are used as the default key dimensions (``kdims``) of the element. We can see this from the default axis labels when visualizing a simple ``Points`` element:"
]
},
{
Expand All @@ -41,14 +41,16 @@
"source": [
"np.random.seed(12)\n",
"coords = np.random.rand(50,2)\n",
"hv.Points(coords).opts(color='black', marker='x')"
"points = hv.Points(coords)\n",
"\n",
"points.opts(color='black', marker='x', size=10)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here both the random *x* values and random *y* values are *both* considered to be the 'data' with no dependency between them (compare this to how [``Scatter``](./Scatter.ipynb) elements are defined). You can think of ``Points`` as simply marking positions in some two-dimensional space that can be sliced by specifying a 2D region-of-interest:"
"Here both the random ``x`` values and random ``y`` values are *both* considered to be the 'data' with no dependency between them (compare this to how [``Scatter``](./Scatter.ipynb) elements are defined). You can think of ``Points`` as simply marking positions in some two-dimensional space that can be sliced by specifying a 2D region-of-interest:"
]
},
{
Expand All @@ -57,8 +59,7 @@
"metadata": {},
"outputs": [],
"source": [
"(hv.Points(coords) + hv.Points(coords)[0.6:0.8,0.2:0.5]).opts(\n",
" opts.Points(color='black', size=10, marker='x'))"
"(points + points[0.6:0.8,0.2:0.5])"
]
},
{
Expand Down
11 changes: 5 additions & 6 deletions examples/reference/elements/plotly/Scatter.ipynb
Expand Up @@ -40,15 +40,16 @@
"outputs": [],
"source": [
"np.random.seed(42)\n",
"coords = [(i, np.random.random()) for i in range(20)]\n",
"hv.Scatter(coords).opts(color='black', size=10, marker='circle')"
"scatter = hv.Scatter(np.random.randn(20).cumsum(axis=0))\n",
"\n",
"scatter.opts(color='black', size=10, marker='circle')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here the random *y* values are considered to be the 'data' whereas the x positions express where those values are located (compare this to how [``Points``](./Points.ipynb) elements are defined). In this sense, ``Scatter`` can be thought of as a [``Curve``](./Curve.ipynb) without any lines connecting the samples and you can use slicing to view the *y* values corresponding to a chosen *x* range:"
"Here the random ``y`` values are considered to be the 'data' whereas the ``x`` positions express where those values are located (compare this to how [``Points``](./Points.ipynb) elements are defined). In this sense, ``Scatter`` can be thought of as a [``Curve``](./Curve.ipynb) without any lines connecting the samples and you can use slicing to view the ```` values corresponding to a chosen ``x`` range:"
]
},
{
Expand All @@ -57,9 +58,7 @@
"metadata": {},
"outputs": [],
"source": [
"(hv.Scatter(coords)[0:12] + hv.Scatter(coords)[12:20]).opts(\n",
" opts.Scatter(color='black', marker='x', size=10)\n",
")"
"(scatter[0:12] + scatter[12:20])"
]
},
{
Expand Down
6 changes: 4 additions & 2 deletions examples/reference/elements/plotly/Spread.ipynb
Expand Up @@ -76,8 +76,10 @@
"outputs": [],
"source": [
"xs = np.linspace(0, np.pi*2, 20)\n",
"hv.Spread((xs, np.sin(xs), 0.1+np.random.rand(len(xs)), 0.1+np.random.rand(len(xs))),\n",
" vdims=['y', 'yerrneg', 'yerrpos']).opts(color='indianred')"
"spread = hv.Spread((xs, np.sin(xs), 0.1+np.random.rand(len(xs)), 0.1+np.random.rand(len(xs))),\n",
" vdims=['y', 'yerrneg', 'yerrpos'])\n",
"\n",
"spread.opts(color='indianred')"
]
},
{
Expand Down
5 changes: 3 additions & 2 deletions examples/reference/elements/plotly/Surface.ipynb
Expand Up @@ -42,8 +42,9 @@
"metadata": {},
"outputs": [],
"source": [
"hv.Surface(np.sin(np.linspace(0,100*np.pi*2,10000)).reshape(100,100)).opts(\n",
" cmap='viridis', height=500, width=500)"
"surface = hv.Surface(np.sin(np.linspace(0,100*np.pi*2,10000)).reshape(100,100))\n",
"\n",
"surface.opts(cmap='viridis', height=500, width=500)"
]
},
{
Expand Down
9 changes: 5 additions & 4 deletions examples/reference/elements/plotly/TriSurface.ipynb
Expand Up @@ -39,8 +39,9 @@
"source": [
"y,x = np.mgrid[-5:5, -5:5] * 0.1\n",
"heights = np.sin(x**2+y**2)\n",
"hv.TriSurface((x.flat,y.flat,heights.flat)).opts(\n",
" height=500, width=500)"
"trisurface = hv.TriSurface((x.flat,y.flat,heights.flat))\n",
"\n",
"trisurface.opts(height=500, width=500)"
]
},
{
Expand Down Expand Up @@ -68,9 +69,9 @@
"y=tp*np.sin(u)\n",
"z=0.5*v*np.sin(u/2.)\n",
"\n",
"surface = hv.TriSurface((x, y, z), label='Moebius band')\n",
"trisurface = hv.TriSurface((x, y, z), label='Moebius band')\n",
"\n",
"surface.opts(cmap='fire', colorbar=True, height=500, width=500)"
"trisurface.opts(cmap='fire', colorbar=True, height=500, width=500)"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion examples/reference/elements/plotly/Violin.ipynb
Expand Up @@ -63,7 +63,7 @@
"violin = hv.Violin((groups, np.random.randint(0, 5, 200), np.random.randn(200)),\n",
" ['Group', 'Category'], 'Value')\n",
"\n",
"violin.opts(height=400, show_legend=False, width=600)"
"violin.opts(height=400, width=600)"
]
},
{
Expand Down

0 comments on commit 71a64f2

Please sign in to comment.