Skip to content

Commit

Permalink
Updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Dec 8, 2018
1 parent 2edba7e commit 9c75c8e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 27 deletions.
25 changes: 13 additions & 12 deletions examples/reference/elements/bokeh/Path.ipynb
Expand Up @@ -21,14 +21,16 @@
"source": [
"import numpy as np\n",
"import holoviews as hv\n",
"from holoviews import opts\n",
"\n",
"hv.extension('bokeh')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A ``Path`` object is actually a collection of lines, unlike ``Curve`` where the y-axis is the dependent variable, a ``Path`` consists of lines connecting arbitrary points in two-dimensional space. The individual subpaths should be supplied as a list and will be stored as NumPy arrays, DataFrames or dictionaries for each column, i.e. any of the formats accepted by columnar data formats. For a full description of the path geometry data model see the [Geometry Data User Guide](../user_guide/Geometry_Data.ipynb). \n",
"A ``Path`` object is actually a collection of lines, unlike ``Curve`` where the y-axis is the dependent variable, a ``Path`` consists of lines connecting arbitrary points in two-dimensional space. ``Path`` supports plotting an individual line or multiple subpaths, which should be supplied as a list. Each path should be defined in a columnar format such as NumPy arrays, DataFrames or dictionaries for each column. For a full description of the path geometry data model see the [Geometry Data User Guide](../user_guide/Geometry_Data.ipynb).\n",
"\n",
"In this example we will create a Lissajous curve, which describe complex harmonic motion:"
]
Expand All @@ -39,14 +41,12 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Path (color='black' line_width=4)\n",
"\n",
"lin = np.linspace(0, np.pi*2, 200)\n",
"\n",
"def lissajous(t, a, b, delta):\n",
" return (np.sin(a * t + delta), np.sin(b * t), t)\n",
"\n",
"hv.Path([lissajous(lin, 3, 5, np.pi/2)])"
"hv.Path([lissajous(lin, 3, 5, np.pi/2)]).opts(color='black', line_width=4)"
]
},
{
Expand All @@ -63,15 +63,15 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Path [color_index='time'] (line_width=4 cmap='hsv')\n",
"hv.Path([lissajous(lin, 3, 5, np.pi/2)], vdims='time')"
"hv.Path([lissajous(lin, 3, 5, np.pi/2)], vdims='time').opts(\n",
" cmap='hsv', color='time', line_width=4)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If we do not provide a ``color_index`` overlaid ``Path`` elements will cycle colors just like other elements do unlike ``Curve`` a single ``Path`` element can contain multiple lines that are disconnected from each other. A ``Path`` can therefore often useful to draw arbitrary annotations on top of an existing plot.\n",
"If we do not provide a ``color`` overlaid ``Path`` elements will cycle colors just like other elements do unlike ``Curve`` a single ``Path`` element can contain multiple lines that are disconnected from each other. A ``Path`` can therefore often useful to draw arbitrary annotations on top of an existing plot.\n",
"\n",
"A ``Path`` Element accepts multiple formats for specifying the paths, the simplest of which is passing a list of ``Nx2`` arrays of the x- and y-coordinates, alternative we can pass lists of coordinates. In this example we will create some coordinates representing rectangles and ellipses annotating an ``RGB`` image:"
]
Expand All @@ -82,15 +82,15 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Path (line_width=4)\n",
"angle = np.linspace(0, 2*np.pi, 100)\n",
"baby = list(zip(0.15*np.sin(angle), 0.2*np.cos(angle)-0.2))\n",
"\n",
"adultR = [(0.25, 0.45), (0.35,0.35), (0.25, 0.25), (0.15, 0.35), (0.25, 0.45)]\n",
"adultL = [(-0.3, 0.4), (-0.3, 0.3), (-0.2, 0.3), (-0.2, 0.4),(-0.3, 0.4)]\n",
"scene = hv.RGB.load_image('../assets/penguins.png')\n",
"\n",
"scene * hv.Path([adultL, adultR, baby]) * hv.Path([baby])"
"(scene * hv.Path([adultL, adultR, baby]) * hv.Path([baby])).opts(\n",
" opts.Path(line_width=4))"
]
},
{
Expand All @@ -106,10 +106,11 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Path [width=600]\n",
"N, NLINES = 100, 10\n",
"hv.Path((np.arange(N), np.random.rand(N, NLINES) + np.arange(NLINES)[np.newaxis, :])) *\\\n",
"hv.Path((np.arange(N), np.random.rand(N, NLINES) + np.arange(NLINES)[np.newaxis, :]))"
"paths = hv.Path((np.arange(N), np.random.rand(N, NLINES) + np.arange(NLINES)[np.newaxis, :]))\n",
"paths2 = hv.Path((np.arange(N), np.random.rand(N, NLINES) + np.arange(NLINES)[np.newaxis, :]))\n",
"\n",
"(paths * paths2).opts(width=600)"
]
},
{
Expand Down
26 changes: 14 additions & 12 deletions examples/reference/elements/matplotlib/Path.ipynb
Expand Up @@ -21,14 +21,16 @@
"source": [
"import numpy as np\n",
"import holoviews as hv\n",
"from holoviews import opts\n",
"\n",
"hv.extension('matplotlib')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A ``Path`` object is actually a collection of lines, unlike ``Curve`` where the y-axis is the dependent variable, a ``Path`` consists of lines connecting arbitrary points in two-dimensional space. The individual subpaths should be supplied as a list and will be stored as NumPy arrays, DataFrames or dictionaries for each column, i.e. any of the formats accepted by columnar data formats. For a full description of the path geometry data model see the [Geometry Data User Guide](../user_guide/Geometry_Data.ipynb). \n",
"A ``Path`` object is actually a collection of lines, unlike ``Curve`` where the y-axis is the dependent variable, a ``Path`` consists of lines connecting arbitrary points in two-dimensional space. ``Path`` supports plotting an individual line or multiple subpaths, which should be supplied as a list. Each path should be defined in a columnar format such as NumPy arrays, DataFrames or dictionaries for each column. For a full description of the path geometry data model see the [Geometry Data User Guide](../user_guide/Geometry_Data.ipynb).\n",
"\n",
"In this example we will create a Lissajous curve, which describe complex harmonic motion:"
]
Expand All @@ -39,14 +41,12 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Path (color='black' linewidth=4)\n",
"\n",
"lin = np.linspace(0, np.pi*2, 200)\n",
"\n",
"def lissajous(t, a, b, delta):\n",
" return (np.sin(a * t + delta), np.sin(b * t), t)\n",
"\n",
"hv.Path([lissajous(lin, 3, 5, np.pi/2)])"
"hv.Path([lissajous(lin, 3, 5, np.pi/2)]).opts(color='black', linewidth=4)"
]
},
{
Expand All @@ -63,15 +63,15 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Path [color_index='time'] (linewidth=4 cmap='hsv')\n",
"hv.Path([lissajous(lin, 3, 5, np.pi/2)], vdims='time')"
"hv.Path([lissajous(lin, 3, 5, np.pi/2)], vdims='time').opts(\n",
" cmap='hsv', color='time', linewidth=4)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If we do not provide a ``color_index`` overlaid ``Path`` elements will cycle colors just like other elements do unlike ``Curve`` a single ``Path`` element can contain multiple lines that are disconnected from each other. A ``Path`` can therefore often useful to draw arbitrary annotations on top of an existing plot.\n",
"If we do not provide a ``color`` overlaid ``Path`` elements will cycle colors just like other elements do unlike ``Curve`` a single ``Path`` element can contain multiple lines that are disconnected from each other. A ``Path`` can therefore often useful to draw arbitrary annotations on top of an existing plot.\n",
"\n",
"A ``Path`` Element accepts multiple formats for specifying the paths, the simplest of which is passing a list of ``Nx2`` arrays of the x- and y-coordinates, alternative we can pass lists of coordinates. In this example we will create some coordinates representing rectangles and ellipses annotating an ``RGB`` image:"
]
Expand All @@ -82,15 +82,16 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Path (linewidth=4)\n",
"angle = np.linspace(0, 2*np.pi, 100)\n",
"baby = list(zip(0.15*np.sin(angle), 0.2*np.cos(angle)-0.2))\n",
"\n",
"adultR = [(0.25, 0.45), (0.35,0.35), (0.25, 0.25), (0.15, 0.35), (0.25, 0.45)]\n",
"adultL = [(-0.3, 0.4), (-0.3, 0.3), (-0.2, 0.3), (-0.2, 0.4),(-0.3, 0.4)]\n",
"scene = hv.RGB.load_image('../assets/penguins.png')\n",
"\n",
"scene * hv.Path([adultL, adultR, baby]) * hv.Path([baby])"
"(scene * hv.Path([adultL, adultR]) * hv.Path(baby)).opts(\n",
" opts.Path(linewidth=4)\n",
")"
]
},
{
Expand All @@ -106,10 +107,11 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Path [aspect=3 fig_size=300]\n",
"N, NLINES = 100, 10\n",
"hv.Path((np.arange(N), np.random.rand(N, NLINES) + np.arange(NLINES)[np.newaxis, :])) *\\\n",
"hv.Path((np.arange(N), np.random.rand(N, NLINES) + np.arange(NLINES)[np.newaxis, :]))"
"paths = hv.Path((np.arange(N), np.random.rand(N, NLINES) + np.arange(NLINES)[np.newaxis, :]))\n",
"paths2 = hv.Path((np.arange(N), np.random.rand(N, NLINES) + np.arange(NLINES)[np.newaxis, :]))\n",
"\n",
"(paths * paths2).opts(aspect=3, fig_size=300)"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions examples/user_guide/Geometry_Data.ipynb
Expand Up @@ -29,7 +29,7 @@
"\n",
"The ``Path`` element represents a collection of path geometries with optional associated values. Each path geometry may be split into sub-geometries on NaN-values and may be associated with scalar values or array values varying along its length. In analogy to GEOS geometry types a Path is a collection of LineString and MultiLineString geometries with associated values.\n",
"\n",
"While many different formats are accepted in theory, natively HoloViews provides support for representing paths as lists of regular columnar data objects including arrays, dataframes and dictionaries of column arrays and scalars. A simple path geometry may therefore be drawn using:"
"While other formats can be supported through extensible interfaces (e.g. geopandas and shapely objects in GeoViews), natively HoloViews provides support for representing paths as one or more columnar data-structures including arrays, dataframes and dictionaries of column arrays and scalars. A simple path geometry may therefore be drawn using:"
]
},
{
Expand All @@ -38,14 +38,14 @@
"metadata": {},
"outputs": [],
"source": [
"hv.Path([{'x': [1, 2, 3, 4, 5], 'y': [0, 0, 1, 1, 2]}]).options(padding=0.1)"
"hv.Path({'x': [1, 2, 3, 4, 5], 'y': [0, 0, 1, 1, 2]}).options(padding=0.1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here the dictionary of x- and y-coordinates could also be an NumPy array with two columns or a dataframe with 'x' and 'y' columns. Since the format supports lists any number of geometries may be drawn in this way. Additionally, it is also possible to associate a value with each path by declaring it as a value dimension:"
"Here the dictionary of x- and y-coordinates could also be an NumPy array with two columns or a dataframe with 'x' and 'y' columns. To draw multiple paths the data-structures can be wrapped in a list. Additionally, it is also possible to associate a value with each path by declaring it as a value dimension:"
]
},
{
Expand Down

0 comments on commit 9c75c8e

Please sign in to comment.