Update 04-Style_Mapping.ipynb
"source": [
"One of the major benefits of HoloViews is the fact that Elements are simple, declarative wrappers around your data, with clearly defined semantics describing how the dimensions of the data map to the screen. Usually the key dimensions (kdims) and value dimensions map to coordinates of the plot axes and/or the colormapped intensity. However there are a huge number of ways to augment the visual representation of an element by mapping dimensions to visual attributes. In this section we will explore how we can declare such mappings including complex transforms specified by so called ``dim`` objects.\n",
"\n",
- "To illustrate this point let us create a set of three points with x/y-coordinates and alpha, color, marker and size values and then map each of those value dimensions to a visual attribute by name:"
+ "To illustrate this point let us create a set of three points with x/y-coordinates and alpha, color, marker and size values and then map each of those value dimensions to a visual attribute by name. Note that by default kdims is x,y. However, in this example we also show that the names of the dimensions can be changed and we use 'x values' and 'y values' to represent the data series names."
]
},
{
"outputs": [],
"source": [
"data = {\n",
- " 'x': [0, 1, 0.5],\n",
- " 'y': [1, 0, 0.5],\n",
+ " 'x values': [0, 1, 0.5],\n",
+ " 'y values': [1, 0, 0.5],\n",
" 'alpha': [0.5, 1, 0.3],\n",
" 'color': ['red', 'blue', 'green'],\n",
" 'marker': ['circle', 'triangle', 'diamond'],\n",
"\n",
"opts.defaults(opts.Points(padding=0.1, size=8, line_color='black'))\n",
"\n",
- "hv.Points(data, vdims=['alpha', 'color', 'marker', 'size']).opts(\n",
+ "hv.Points(data, kdims=['x values','y values'] , vdims=['alpha', 'color', 'marker', 'size']).opts(\n",
" alpha='alpha', color='color', marker='marker', size='size')"
]
},
{
"cell_type": "code",
"execution_count": null,
- "metadata": {},
+ "metadata": {
+ "scrolled": true
+ },
"outputs": [],
"source": [
"ellipses = hv.Overlay([hv.Ellipse(0, 0, s) for s in range(6)])\n",
}
],
"metadata": {
+ "kernelspec": {
+ "display_name": "Python 2",
+ "language": "python",
+ "name": "python2"
+ },
"language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 2
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
"name": "python",
- "pygments_lexer": "ipython3"
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython2",
+ "version": "2.7.16"
}
},
"nbformat": 4,
