"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import holoviews as hv\n",
"hv.extension('matplotlib')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A Overlay is a collection of HoloViews objects that are related in some way, to be displayed simultanously, overlaid in the space space. Like [``Layout``](./Layout.ipynb) and unlike other containers such as [``HoloMap``](./HoloMap.ipynb) , [``GridSpace``](./GridSpace.ipynb) and [``NdOverlay``](./NdOverlay.ipynb) a ``Overlay`` is *not* dictionary like: it holds potentially heterogeneous types without any dimensioned keys.\n",
"\n",
"\n",
"A ``Overlay`` cannot contain any other container type other than ``NdOverlay`` but can contain any HoloViews elements. See [Building Composite Objects](../../../user_guide/06-Building_Composite_Objects.ipynb) for more details on how to compose containers. It is best to learn about ``Overlay`` and [``Layout``](./Layout.ipynb) together as they are very closely related objects that share many core concepts."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### ``Overlay`` is a heterogeneous collection"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can build a ``Overlay`` between any two HoloViews objects (which can have different types) using the ``*`` operator:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"xvals = [0.1* i for i in range(100)]\n",
"curve = hv.Curve((xvals, [np.sin(x) for x in xvals]))\n",
"scatter = hv.Scatter((xvals[::5], np.linspace(0,1,20)))\n",
"curve * scatter"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this example, we have a ``Overlay`` composed of a ``Curve`` element and a ``Scatter`` element.\n",
"\n",
"For more information about both ``Overlay`` and ``Layout``, see the [Composing_Elements](../../../user_guide/02-Composing_Elements.ipynb) user guide."
]
}
],
"metadata": {
"language_info": {
"name": "python",
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}