Last active
July 20, 2021 08:43
-
-
Save peterroelants/32fadcdf4d27ff6228178fa9a8a2252b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"id": "2f3f9394-0609-43e4-9b73-3602fa4c4bb7", | |
"metadata": {}, | |
"source": [ | |
"# Test Overlay.hist" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "ba07e8bf-c7ac-4c49-b918-c256b8b28bf4", | |
"metadata": {}, | |
"source": [ | |
"## Test NdOverlay" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "fbb18b35-4918-43fc-98b2-b783920df56d", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import numpy as np\n", | |
"import holoviews as hv\n", | |
"\n", | |
"hv.extension('bokeh')\n", | |
"\n", | |
"\n", | |
"points_dct = {\n", | |
" 'p1': hv.Points(np.random.randn(1000, 2), kdims=['x', 'y'], label='p1'),\n", | |
" 'p2': hv.Points(np.random.randn(1000, 2) -5, kdims=['x', 'y'], label='p2')\n", | |
"}\n", | |
"nd_overlay = hv.NdOverlay(points_dct, kdims='cat')\n", | |
"plot = nd_overlay.hist()\n", | |
"print(repr(plot))\n", | |
"plot" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "5a68c4fe-8426-40fe-a92c-42e2877a4d91", | |
"metadata": {}, | |
"source": [ | |
"### Test NdOverlay with given dimensions" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "cb64434e-48c5-428f-8941-46444ff97116", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import numpy as np\n", | |
"import holoviews as hv\n", | |
"\n", | |
"hv.extension('bokeh')\n", | |
"\n", | |
"\n", | |
"points_dct = {\n", | |
" 'p1': hv.Points(np.random.randn(1000, 2), kdims=['x', 'y'], label='p1'),\n", | |
" 'p2': hv.Points(np.random.randn(1000, 2) -5, kdims=['x', 'y'], label='p2')\n", | |
"}\n", | |
"nd_overlay = hv.NdOverlay(points_dct, kdims='cat')\n", | |
"plot = nd_overlay.hist(dimension=['x','y'])\n", | |
"print(repr(plot))\n", | |
"plot" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "0db7a4fc-4d71-452f-9e43-81d046cb92ea", | |
"metadata": {}, | |
"source": [ | |
"### Test NdOverlay colormap" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "111e1319-22bb-4e51-b98e-7f79a299491f", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import numpy as np\n", | |
"import holoviews as hv\n", | |
"\n", | |
"hv.extension('bokeh')\n", | |
"\n", | |
"color_cycle = hv.Cycle(['green', 'purple', 'yellow'])\n", | |
"\n", | |
"\n", | |
"points_dct = {\n", | |
" 'p1': hv.Points(np.random.randn(1000, 2), kdims=['x', 'y'], label='p1'),\n", | |
" 'p2': hv.Points(np.random.randn(1000, 2) -5, kdims=['x', 'y'], label='p2')\n", | |
"}\n", | |
"nd_overlay = hv.NdOverlay(points_dct, kdims='cat').options(hv.opts.Points(color=color_cycle))\n", | |
"plot = nd_overlay.hist(dimension=['x','y']).opts(hv.opts.Histogram(color=color_cycle))\n", | |
"print(repr(plot))\n", | |
"plot" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "0173496f-3571-4eaf-9bcb-ae53dcfe8e33", | |
"metadata": {}, | |
"source": [ | |
"### Test NdOverlay without adjoint" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "d4f225c8-7a83-4ff4-b857-b40a5675655f", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import numpy as np\n", | |
"import holoviews as hv\n", | |
"\n", | |
"hv.extension('bokeh')\n", | |
"\n", | |
"\n", | |
"points_dct = {\n", | |
" 'p1': hv.Points(np.random.randn(1000, 2), kdims=['x', 'y'], label='p1'),\n", | |
" 'p2': hv.Points(np.random.randn(1000, 2) -5, kdims=['x', 'y'], label='p2')\n", | |
"}\n", | |
"nd_overlay = hv.NdOverlay(points_dct, kdims='cat')\n", | |
"plot = nd_overlay.hist(dimension=['x','y'], adjoin=False)\n", | |
"print(repr(plot))\n", | |
"plot" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "28b29f13-dd0b-4aad-b1d4-9175caa06aee", | |
"metadata": {}, | |
"source": [ | |
"### Test NdOverlay with label index" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "13649114-4761-4052-a4cb-ec47259c3151", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import numpy as np\n", | |
"import holoviews as hv\n", | |
"\n", | |
"hv.extension('bokeh')\n", | |
"\n", | |
"\n", | |
"points_dct = {\n", | |
" 'p1': hv.Points(np.random.randn(1000, 2), kdims=['x', 'y'], label='p1'),\n", | |
" 'p2': hv.Points(np.random.randn(1000, 2) -5, kdims=['x', 'y'], label='p2')\n", | |
"}\n", | |
"nd_overlay = hv.NdOverlay(points_dct, kdims='cat')\n", | |
"plot = nd_overlay.hist(dimension=['x','y'], index='p2')\n", | |
"print(repr(plot))\n", | |
"plot" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "e409ecea-f5e8-437e-b824-23a17a1ac8dc", | |
"metadata": {}, | |
"source": [ | |
"### Test NdOverlay with integer index" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "a41ebb14-0740-4602-bcf2-866b4ded5d89", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import numpy as np\n", | |
"import holoviews as hv\n", | |
"\n", | |
"hv.extension('bokeh')\n", | |
"\n", | |
"\n", | |
"points_dct = {\n", | |
" 'p1': hv.Points(np.random.randn(1000, 2), kdims=['x', 'y'], label='p1'),\n", | |
" 'p2': hv.Points(np.random.randn(1000, 2) -5, kdims=['x', 'y'], label='p2')\n", | |
"}\n", | |
"nd_overlay = hv.NdOverlay(points_dct, kdims='cat')\n", | |
"plot = nd_overlay.hist(dimension=['x','y'], index=0)\n", | |
"print(repr(plot))\n", | |
"plot" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "cc0144cc-2d43-42de-9bb7-271fa38abe66", | |
"metadata": {}, | |
"source": [ | |
"### Test NdOverlay with single dimension" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "7f8b17c3-8cc8-44c0-85a4-6eae38cd397e", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import numpy as np\n", | |
"import holoviews as hv\n", | |
"\n", | |
"hv.extension('bokeh')\n", | |
"\n", | |
"\n", | |
"points_dct = {\n", | |
" 'p1': hv.Points(np.random.randn(1000, 2), kdims=['x', 'y'], label='p1'),\n", | |
" 'p2': hv.Points(np.random.randn(1000, 2) -5, kdims=['x', 'y'], label='p2')\n", | |
"}\n", | |
"nd_overlay = hv.NdOverlay(points_dct, kdims='cat')\n", | |
"plot = nd_overlay.hist(dimension='x')\n", | |
"print(repr(plot))\n", | |
"plot" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "28c8e631-2952-4d9f-94e1-8cadb5f6fe8c", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import numpy as np\n", | |
"import holoviews as hv\n", | |
"\n", | |
"hv.extension('bokeh')\n", | |
"\n", | |
"\n", | |
"points_dct = {\n", | |
" 'p1': hv.Points(np.random.randn(1000, 2), kdims=['x', 'y'], label='p1'),\n", | |
" 'p2': hv.Points(np.random.randn(1000, 2) -5, kdims=['x', 'y'], label='p2')\n", | |
"}\n", | |
"nd_overlay = hv.NdOverlay(points_dct, kdims='cat')\n", | |
"plot = nd_overlay.hist(dimension='y')\n", | |
"print(repr(plot))\n", | |
"plot" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "f33e8286-8f9e-44f6-8ff4-2cec6a1dc2de", | |
"metadata": {}, | |
"source": [ | |
"## Test Overlay" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "6d294a61-930e-46c0-b64b-5a1253cf7a64", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import numpy as np\n", | |
"import holoviews as hv\n", | |
"\n", | |
"hv.extension('bokeh')\n", | |
"\n", | |
"\n", | |
"pts1 = hv.Points(np.random.randn(1000, 2) , kdims=['x', 'y'], label='p1l')\n", | |
"pts2 = hv.Points(np.random.randn(1000, 2) - 5, kdims=['x', 'y'], label='p2l')\n", | |
"pts_overlay = hv.Overlay([pts1, pts2])\n", | |
"plot = pts_overlay.hist()\n", | |
"print(repr(plot))\n", | |
"plot" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "bbed3441-a7db-478d-807f-807042db4521", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import numpy as np\n", | |
"import holoviews as hv\n", | |
"\n", | |
"hv.extension('bokeh')\n", | |
"\n", | |
"\n", | |
"pts1 = hv.Points(np.random.randn(1000, 2) , kdims=['x', 'y'], label='p1l')\n", | |
"pts2 = hv.Points(np.random.randn(1000, 2) - 5, kdims=['x', 'y'], label='p2l')\n", | |
"pts_overlay = pts1 * pts2\n", | |
"plot = pts_overlay.hist()\n", | |
"print(repr(plot))\n", | |
"plot" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "b302dcf4-0cf6-41f8-985f-1f7e9520bd64", | |
"metadata": {}, | |
"source": [ | |
"### Test Overlay with given dimensions" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "c25d00f1-e8d1-4b32-8189-a719b575569b", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import numpy as np\n", | |
"import holoviews as hv\n", | |
"\n", | |
"hv.extension('bokeh')\n", | |
"\n", | |
"\n", | |
"pts1 = hv.Points(np.random.randn(1000, 2) , kdims=['x', 'y'], label='p1l')\n", | |
"pts2 = hv.Points(np.random.randn(1000, 2) - 5, kdims=['x', 'y'], label='p2l')\n", | |
"pts_overlay = pts1 * pts2\n", | |
"plot = pts_overlay.hist(dimension=['x','y'])\n", | |
"print(repr(plot))\n", | |
"plot" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "0060f122-fd21-463a-b641-788cd3a2f5fc", | |
"metadata": {}, | |
"source": [ | |
"### Test Overlay colormap" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "e112116f-07c5-47e0-aaa1-65c328a0499b", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import numpy as np\n", | |
"import holoviews as hv\n", | |
"\n", | |
"hv.extension('bokeh')\n", | |
"\n", | |
"color_cycle = hv.Cycle(['green', 'purple', 'yellow'])\n", | |
"\n", | |
"pts1 = hv.Points(np.random.randn(1000, 2) , kdims=['x', 'y'], label='p1l')\n", | |
"pts2 = hv.Points(np.random.randn(1000, 2) - 5, kdims=['x', 'y'], label='p2l')\n", | |
"pts_overlay = (pts1 * pts2).options(hv.opts.Points(color=color_cycle))\n", | |
"plot = pts_overlay.hist(dimension=['x','y']).opts(hv.opts.Histogram(color=color_cycle))\n", | |
"print(repr(plot))\n", | |
"plot" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "89cc800f-2d22-4bd5-8975-31cf2a6d36d2", | |
"metadata": {}, | |
"source": [ | |
"### Test overlay single dimension" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "d8cafa3c-c4d3-45ac-ac2a-30d6eafba311", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import numpy as np\n", | |
"import holoviews as hv\n", | |
"\n", | |
"hv.extension('bokeh')\n", | |
"\n", | |
"\n", | |
"pts1 = hv.Points(np.random.randn(1000, 2) , kdims=['x', 'y'], label='p1l')\n", | |
"pts2 = hv.Points(np.random.randn(1000, 2) - 5, kdims=['x', 'y'], label='p2l')\n", | |
"pts_overlay = pts1 * pts2\n", | |
"plot = pts_overlay.hist(dimension='x')\n", | |
"print(repr(plot))\n", | |
"plot" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "ae50d792-6e16-41fc-94da-d2a83e258dab", | |
"metadata": {}, | |
"source": [ | |
"## Test regular element" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "267a4d15-61af-48b4-8445-7a47762ce3bc", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import numpy as np\n", | |
"import holoviews as hv\n", | |
"\n", | |
"hv.extension('bokeh')\n", | |
"\n", | |
"\n", | |
"pts = hv.Points(np.random.randn(1000, 2), kdims=['x', 'y'], label='p1')\n", | |
"pts.hist(dimension=['x','y'])" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3 (ipykernel)", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.9.6" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment