Skip to content

Commit

Permalink
Merge 01fe7e0 into d5feee5
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Nov 20, 2018
2 parents d5feee5 + 01fe7e0 commit 3d94fb8
Show file tree
Hide file tree
Showing 95 changed files with 4,519 additions and 674 deletions.
2 changes: 1 addition & 1 deletion examples/gallery/demos/bokeh/autompg_histogram.ipynb
Expand Up @@ -53,7 +53,7 @@
"outputs": [],
"source": [
"%%opts Histogram (alpha=0.9) [width=600]\n",
"autompg_ds.hist(dimension='mpg', groupby='cyl', adjoin=False)"
"autompg_ds.hist(dimension='mpg', groupby='cyl', bin_range=(9, 46), bins=40, adjoin=False)"
]
}
],
Expand Down
2 changes: 1 addition & 1 deletion examples/gallery/demos/bokeh/autompg_violins.ipynb
Expand Up @@ -50,7 +50,7 @@
"metadata": {},
"outputs": [],
"source": [
"violin.options(height=500, width=900)"
"violin.options(height=500, width=900, violin_fill_color=('Year', str), cmap='Set1')"
]
}
],
Expand Down
4 changes: 2 additions & 2 deletions examples/gallery/demos/bokeh/bars_economic.ipynb
Expand Up @@ -53,9 +53,9 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Bars [stack_index=1 xrotation=90 width=600 show_legend=False tools=['hover']]\n",
"%%opts Bars [stacked=True xrotation=90 width=600 show_legend=False tools=['hover']]\n",
"%%opts Bars (color=Cycle('Category20'))\n",
"macro.to.bars([ 'Year', 'Country'], 'Trade', [])"
"macro.to.bars(['Year', 'Country'], 'Trade', [])"
]
}
],
Expand Down
2 changes: 1 addition & 1 deletion examples/gallery/demos/bokeh/boxplot_chart.ipynb
Expand Up @@ -53,7 +53,7 @@
"metadata": {},
"outputs": [],
"source": [
"boxwhisker.options(show_legend=False, width=400)"
"boxwhisker.options(show_legend=False, width=600, box_fill_color=('origin', str), cmap='Set1')"
]
}
],
Expand Down
4 changes: 2 additions & 2 deletions examples/gallery/demos/bokeh/choropleth_data_link.ipynb
Expand Up @@ -70,8 +70,8 @@
"metadata": {},
"outputs": [],
"source": [
"choropleth.options(width=500, height=500, tools=['hover', 'tap'], xaxis=None, yaxis=None, color_index='Unemployment', clone=False)\n",
"table.options(height=428, clone=False)\n",
"choropleth = choropleth.options(width=500, height=500, tools=['hover', 'tap'], xaxis=None, yaxis=None, color_index='Unemployment')\n",
"table = table.options(height=428)\n",
"\n",
"# Link the choropleth and the table\n",
"DataLink(choropleth, table)\n",
Expand Down
14 changes: 2 additions & 12 deletions examples/gallery/demos/bokeh/dragon_curve.ipynb
Expand Up @@ -107,21 +107,11 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Path {+framewise} [xaxis=None yaxis=None title_format=''] (color='black' line_width=1)\n",
"%%opts Path {+framewise} [xaxis=None yaxis=None title_format='' padding=0.1] (color='black' line_width=1)\n",
"\n",
"def pad_extents(path):\n",
" \"Add 5% padding around the path\"\n",
" minx, maxx = path.range('x')\n",
" miny, maxy = path.range('y')\n",
" xpadding = ((maxx-minx) * 0.1)/2\n",
" ypadding = ((maxy-miny) * 0.1)/2\n",
" path.extents = (minx-xpadding, miny-ypadding, maxx+xpadding, maxy+ypadding)\n",
" return path\n",
" \n",
"hmap = hv.HoloMap(kdims='Iteration')\n",
"for i in range(7,17):\n",
" path = DragonCurve(-200, 0, i).path\n",
" hmap[i] = pad_extents(path)\n",
" hmap[i] = DragonCurve(-200, 0, i).path\n",
"hmap"
]
}
Expand Down
2 changes: 1 addition & 1 deletion examples/gallery/demos/bokeh/dropdown_economic.ipynb
Expand Up @@ -54,7 +54,7 @@
"outputs": [],
"source": [
"%%opts Overlay [width=700 height=400 show_frame=False]\n",
"%%opts Curve (color='k') Scatter [color_index=2 size_index=2 scaling_factor=1.4] (cmap='Blues' line_color='k')\n",
"%%opts Curve (color='k') Scatter (color='Unemployment' size=dim('Unemployment')*1.5 cmap='Blues' line_color='k')\n",
"%%opts VLine (color='k' line_width=1)\n",
"%%opts Text (text_font_size='13px')\n",
"gdp_curves = macro.to.curve('Year', 'GDP Growth')\n",
Expand Down
4 changes: 2 additions & 2 deletions examples/gallery/demos/bokeh/quiver_demo.ipynb
Expand Up @@ -77,8 +77,8 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts VectorField [width=500 color_index=3 size_index=3 pivot='tip'] Points (color='black')\n",
"hv.VectorField((xs, ys, angle, mag), label=\"pivot='tip'; scales with x view\") * hv.Points((X.flat, Y.flat))"
"%%opts VectorField [width=500 magnitude='Magnitude' pivot='tip'] (line_width=2 color='Magnitude') Points (color='black')\n",
"hv.Points((X.flat, Y.flat)) * hv.VectorField((xs, ys, angle, mag), label=\"pivot='tip'; scales with x view\")"
]
}
],
Expand Down
2 changes: 1 addition & 1 deletion examples/gallery/demos/matplotlib/dropdown_economic.ipynb
Expand Up @@ -53,7 +53,7 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Curve (color='k') Scatter [color_index=2 size_index=2 scaling_factor=1.4] (cmap='Blues' edgecolors='k')\n",
"%%opts Curve (color='k') Scatter (color='Unemployment' s=dim('Unemployment')*10 cmap='Blues' edgecolors='k')\n",
"%%opts Overlay [show_frame=True aspect=2, fig_size=250, show_frame=False]\n",
"gdp_curves = macro.to.curve('Year', 'GDP Growth')\n",
"gdp_unem_scatter = macro.to.scatter('Year', ['GDP Growth', 'Unemployment'])\n",
Expand Down
2 changes: 1 addition & 1 deletion examples/gallery/demos/matplotlib/quiver_demo.ipynb
Expand Up @@ -77,7 +77,7 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts VectorField [aspect=1.5 fig_size=200 size_index=3 color_index=3] (pivot='tip') Points (color='black' s=5)\n",
"%%opts VectorField [aspect=1.5 fig_size=200 magnitude='Magnitude'] (color='Magnitude' pivot='tip') Points (color='black' s=5)\n",
"hv.VectorField((xs, ys, angle, mag), label=\"pivot='tip'; scales with x view\") * hv.Points((X.flat, Y.flat))"
]
}
Expand Down
6 changes: 3 additions & 3 deletions examples/reference/elements/bokeh/Bars.ipynb
Expand Up @@ -30,7 +30,7 @@
"source": [
"The ``Bars`` Element uses bars to show discrete, numerical comparisons across categories. One axis of the chart shows the specific categories being compared and the other axis represents a continuous value.\n",
"\n",
"Bars may also be stacked by supplying a second key dimensions representing sub-categories. Therefore the ``Bars`` Element expects a tabular data format with one or two key dimensions and one value dimension. See the [Tabular Datasets](../../../user_guide/07-Tabular_Datasets.ipynb) user guide for supported data formats, which include arrays, pandas dataframes and dictionaries of arrays."
"Bars may also be grouped or stacked by supplying a second key dimension representing sub-categories. Therefore the ``Bars`` Element expects a tabular data format with one or two key dimensions (``kdims``) and one or more value dimensions (``vdims``). See the [Tabular Datasets](../../../user_guide/07-Tabular_Datasets.ipynb) user guide for supported data formats, which include arrays, pandas dataframes and dictionaries of arrays."
]
},
{
Expand Down Expand Up @@ -64,7 +64,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"``Bars`` support stacking just like the ``Area`` element as well as grouping by a second key dimension. To activate grouping and stacking set the ``group_index`` or ``stack_index`` to the dimension name or dimension index:"
"``Bars`` support nested categorical grouping as well as stacking if more than one key dimension is defined, to switch between the two set ``stacked=True/False``:"
]
},
{
Expand All @@ -73,7 +73,7 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Bars.Grouped [group_index='Group'] Bars.Stacked [stack_index='Group']\n",
"%%opts Bars.Stacked [stacked=True]\n",
"from itertools import product\n",
"np.random.seed(3)\n",
"index, groups = ['A', 'B'], ['a', 'b']\n",
Expand Down
18 changes: 17 additions & 1 deletion examples/reference/elements/bokeh/Histogram.ipynb
Expand Up @@ -48,7 +48,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The ``Histogram`` Element will also expand evenly sampled bin centers, therefore we can easily cast between a linearly sampled Curve or Scatter and a Histogram."
"The ``Histogram`` Element will also expand evenly sampled bin centers, therefore we can easily cast between a linearly sampled ``Curve`` or ``Scatter`` and a ``Histogram``."
]
},
{
Expand All @@ -63,6 +63,22 @@
"curve + hv.Histogram(curve)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Like most other elements a ``Histogram`` also supports using ``dim`` transforms to map dimensions to visual attributes. To demonstrate this we will use the ``bin`` op to bin the 'y' values into positive and negative values and map those to a 'blue' and 'red' ``fill_color``:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"hv.Histogram(curve).options(fill_color=hv.dim('y').bin(bins=[-1, 0, 1], labels=['red', 'blue']))"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
4 changes: 2 additions & 2 deletions examples/reference/elements/bokeh/Labels.ipynb
Expand Up @@ -72,7 +72,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"If the value dimension of the data is not already of string type it will be formatted using the applicable entry in ``Dimension.type_formatters`` or an explicit ``value_format`` defined on the Dimension. Additionally the ``color_index`` option allows us to colormap the text by a dimension.\n",
"If the value dimension of the data is not already of string type it will be formatted using the applicable entry in ``Dimension.type_formatters`` or an explicit ``value_format`` defined on the Dimension. Additionally the ``text_color`` option allows us to colormap the text by a dimension.\n",
"\n",
"Here we will create a 2D array of values, define a Dimension with a formatter and then colormap the text:"
]
Expand All @@ -88,7 +88,7 @@
"zs = np.sin(xs**2)*np.sin(ys**2)[:, np.newaxis]\n",
"\n",
"hv.Labels((xs, ys, zs), vdims=value_dimension).options(\n",
" bgcolor='black', cmap='magma', color_index='Values', height=400, text_font_size='6pt', width=400\n",
" bgcolor='black', cmap='magma', text_color='Values', height=400, text_font_size='6pt', width=400\n",
")"
]
}
Expand Down
10 changes: 5 additions & 5 deletions examples/reference/elements/bokeh/Points.ipynb
Expand Up @@ -28,7 +28,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 @@ -47,7 +47,7 @@
"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 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 @@ -64,7 +64,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Although the simplest ``Points`` element simply mark positions in a two-dimensional space without any associated value this doesn't mean value dimensions aren't supported. Here is an example with two additional quantities for each point, declared as the ``value_dimension``s *z* and α visualized as the color and size of the dots, respectively:"
"Although the simplest ``Points`` element simply mark positions in a two-dimensional space without any associated value this doesn't mean value dimensions (``vdims``) aren't supported. Here is an example with two additional quantities for each point, declared as the ``vdims`` ``'z'`` and ``'size'`` visualized as the color and size of the dots, respectively:"
]
},
{
Expand All @@ -73,12 +73,12 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Points [color_index=2 size_index=3 scaling_factor=50]\n",
"%%opts Points (color='z' size=dim('size')*20)\n",
"np.random.seed(10)\n",
"data = np.random.rand(100,4)\n",
"\n",
"points = hv.Points(data, vdims=['z', 'size'])\n",
"points + points[0.3:0.7, 0.3:0.7].hist()"
"points + points[0.3:0.7, 0.3:0.7].hist('z')"
]
},
{
Expand Down
10 changes: 5 additions & 5 deletions examples/reference/elements/bokeh/Scatter.ipynb
Expand Up @@ -28,7 +28,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The ``Scatter`` element visualizes as markers placed in a space of one independent variable, traditionally denoted as *x*, against a dependent variable, traditonally denoted as *y*. In HoloViews, the name ``'x'`` is the default dimension name used in the ``key_dimensions`` and ``'y'`` is the default dimension name used in the ``value_dimensions``. We can see this from the default axis labels when visualizing a simple ``Scatter`` element:"
"The ``Scatter`` element visualizes as markers placed in a space of one independent variable, traditionally denoted as *x*, against a dependent variable, traditionally denoted as *y*. In HoloViews, the name ``'x'`` is the default dimension name used in the key dimensions (``kdims``) and ``'y'`` is the default dimension name used in the value dimensions (``vdims``). We can see this from the default axis labels when visualizing a simple ``Scatter`` element:"
]
},
{
Expand Down Expand Up @@ -64,7 +64,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"A ``Scatter`` element must always have at least one value dimension but that doesn't mean additional value dimensions aren't supported. Here is an example with two additional quantities for each point, declared as the ``value_dimension``s *z* and α visualized as the color and size of the dots, respectively:"
"A ``Scatter`` element must always have at least one value dimension but that doesn't mean additional value dimensions aren't supported. Here is an example with two additional quantities for each point, declared as the ``vdims`` ``'z'`` and ``'size'`` visualized as the color and size of the dots, respectively:"
]
},
{
Expand All @@ -73,19 +73,19 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Scatter [color_index=2 size_index=3 scaling_factor=50]\n",
"%%opts Scatter (color='z' size=dim('size')*20)\n",
"np.random.seed(10)\n",
"data = np.random.rand(100,4)\n",
"\n",
"scatter = hv.Scatter(data, vdims=['y', 'z', 'size'])\n",
"scatter + scatter[0.3:0.7, 0.3:0.7].hist()"
"scatter + scatter[0.3:0.7, 0.3:0.7].hist('z')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In the right subplot, the ``hist`` method is used to show the distribution of samples along our first value dimension, (*y*)."
"In the right subplot, the ``hist`` method is used to show the distribution of samples along our first value dimension, (``'y'``)."
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions examples/reference/elements/bokeh/Spikes.ipynb
Expand Up @@ -66,7 +66,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"When supplying a second dimension to the ``Spikes`` element as a value dimension, these additional values will be mapped onto the line height. Optionally, you may also supply a colormap ``cmap`` and ``color_index`` to map the value dimensions to a suitable set of colors. This way we can, for example, plot a [mass spectrogram](https://en.wikipedia.org/wiki/Mass_spectrometry):"
"When supplying a second dimension to the ``Spikes`` element as a value dimension, these additional values will be mapped onto the line height. Optionally, it is also possible to map dimensions to style options. This way we can, for example, plot a [mass spectrogram](https://en.wikipedia.org/wiki/Mass_spectrometry):"
]
},
{
Expand All @@ -75,15 +75,15 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Spikes [color_index='Intensity'] (cmap='Reds')\n",
"%%opts Spikes (color='Intensity' cmap='Reds')\n",
"hv.Spikes(np.random.rand(20, 2), 'Mass', 'Intensity')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Another possibility is to draw a number of spike trains representing the firing of neurons, of the sort that are commonly encountered in neuroscience. Here we generate 10 separate random spike trains and distribute them evenly across the space by setting their ``position``. By declaring some ``yticks``, each spike train can be labeled individually:"
"Another possibility is to draw a set of Spikes offset by a position, which can be useful for plotting discrete events like neurons firing. Here we generate 10 separate random spike trains and distribute them evenly across the space by setting their ``position``. By declaring some ``yticks``, each spike train can be labeled individually:"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion examples/reference/elements/bokeh/TriMesh.ipynb
Expand Up @@ -151,7 +151,7 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts TriMesh [filled=True edge_color_index='z' width=400 height=400 tools=['hover'] inspection_policy='edges'] (cmap='viridis')\n",
"%%opts TriMesh [filled=True width=400 height=400 tools=['hover'] inspection_policy='edges'] (cmap='viridis' edge_color='z')\n",
"hv.TriMesh((simplices, nodes))"
]
},
Expand Down
10 changes: 5 additions & 5 deletions examples/reference/elements/bokeh/VectorField.ipynb
Expand Up @@ -37,7 +37,7 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts VectorField [size_index=3]\n",
"%%opts VectorField [magnitude='Magnitude']\n",
"x,y = np.mgrid[-10:10,-10:10] * 0.25\n",
"sine_rings = np.sin(x**2+y**2)*np.pi+np.pi\n",
"exp_falloff = 1/np.exp((x**2+y**2)/8)\n",
Expand All @@ -61,15 +61,15 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts VectorField [size_index=3] VectorField.A [color_index=2] VectorField.M [color_index=3]\n",
"%%opts VectorField [magnitude='Magnitude'] VectorField.A (color='Angle') VectorField.M (color='Magnitude')\n",
"hv.VectorField(vector_data, group='A') + hv.VectorField(vector_data, group='M')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"By default the arrows are rescaled to the minimum distance between individual arrows, to disable this rescaling set ``rescale=False`` and adjust the ``scale`` manually (smaller values result in larger arrows). This allows fixed scaling even when plotting arrows in an animation. Here we will vary the arrow angle with a Phase dimension and also add this angle to the magnitude data, showing the arrow angles and magnitudes varying. Due to the fixed scaling we can make out the differences across frames:"
"By default the magnitudes are rescaled to the minimum distance between individual arrows, to disable this rescaling set ``rescale_lengths=False`` use a dimension value transform to scale the size of the arrows, e.g. below we normalize the `'Magnitude'` dimension values and then scale them by a factor of `0.2`. This allows fixed scaling even when plotting arrows in an animation. Here we will vary the arrow angle with a Phase dimension and also add this angle to the magnitude data, showing the arrow angles and magnitudes varying. Due to the fixed scaling we can make out the differences across frames:"
]
},
{
Expand All @@ -78,7 +78,7 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts VectorField [color_index=2 size_index=3 rescale_lengths=False] (scale=4)\n",
"%%opts VectorField [magnitude=dim('Magnitude').norm()*0.2 rescale_lengths=False] (color='Angle')\n",
"hv.HoloMap({phase: hv.VectorField([x, y,(vector_data[2]+phase)%np.pi*2, vector_data[3]+np.abs(phase)])\n",
" for phase in np.linspace(-np.pi,np.pi,5)}, kdims='Phase')"
]
Expand Down Expand Up @@ -119,7 +119,7 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts VectorField [width=500 color_index=3 size_index=3 pivot='tip'] (cmap='fire' scale=0.8) Points (color='black' size=1)\n",
"%%opts VectorField [width=500 magnitude='Magnitude' pivot='tip'] (cmap='fire' line_width=1.5 color='Magnitude') Points (color='black' size=1)\n",
"hv.VectorField((xs, ys, angle, mag)) * hv.Points((X.flat, Y.flat))"
]
},
Expand Down
16 changes: 16 additions & 0 deletions examples/reference/elements/matplotlib/Histogram.ipynb
Expand Up @@ -63,6 +63,22 @@
"curve + hv.Histogram(curve)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Like most other elements a ``Histogram`` also supports using ``dim`` transforms to map dimensions to visual attributes. To demonstrate this we will use the ``bin`` transform to bin the 'y' values into positive and negative values and map those to a 'blue' and 'red' ``fill_color``:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"hv.Histogram(curve).options(color=hv.dim('y').bin(bins=[-1, 0, 1], labels=['red', 'blue']))"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down

0 comments on commit 3d94fb8

Please sign in to comment.