Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for dim transforms to set style options #2152

Merged
merged 117 commits into from
Nov 22, 2018
Merged
Show file tree
Hide file tree
Changes from 70 commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
c6ac9a2
Added ops
philippjfr Nov 25, 2017
bc6c1d3
Implement NumPy support for ops
philippjfr Nov 25, 2017
1a909df
Support scalar ops in plotting
philippjfr Nov 25, 2017
c503afb
Various improvements for ops
philippjfr Mar 3, 2018
dc27124
Improved handling for op style mappings
philippjfr Jun 23, 2018
073cbf4
Enabled op style mapping on Composite glyphs
philippjfr Jun 23, 2018
1f09d59
Handle scalar values in ops mapping
philippjfr Jun 24, 2018
ddd5a65
Fixed handling of multi-interface in ops
philippjfr Jun 25, 2018
a076722
Enabled ops mapping for mpl Labels
philippjfr Jun 25, 2018
b2ec022
Improved of unsupported matplotlib ops mapping
philippjfr Jun 25, 2018
93d1cbd
Add unit tests for bokeh PointPlot ops
philippjfr Sep 23, 2018
a8d515a
Fixes and improvements for Point mappings
philippjfr Sep 24, 2018
5100e5e
Fixed flakes and tests
philippjfr Sep 24, 2018
09d6ab8
Fixed op colormapping in matplotlib
philippjfr Sep 24, 2018
bc2e1cd
Added unit tests for matplotlib PointPlot op mapping
philippjfr Sep 24, 2018
b8fdc0b
Created new module for bokeh styles and utilities
philippjfr Oct 29, 2018
b5c0191
Improved validation of op mappings
philippjfr Nov 9, 2018
8f6defa
Improved ops validation and added tests
philippjfr Nov 9, 2018
df80c26
Fixes for op ranges
philippjfr Nov 10, 2018
a8276a6
Add style mapping tests for SpikePlot
philippjfr Nov 10, 2018
f96674f
Various smaller fixes
philippjfr Nov 10, 2018
d19ca7f
Updated Styling_Plots user guide
philippjfr Nov 10, 2018
5db683a
Updated Geometry Data notebook
philippjfr Nov 10, 2018
5459a16
Added bin and cat op functions
philippjfr Nov 10, 2018
2e9c216
Fixed op range resolution
philippjfr Nov 10, 2018
24873f6
Fixes for CompositeElementPlot
philippjfr Nov 10, 2018
3484fa7
Disabled style mapping for Rasters
philippjfr Nov 10, 2018
f287c5f
Enabled style mapping for stats plots
philippjfr Nov 10, 2018
4b6cc37
Improved op transforms to allow construction from tuple
philippjfr Nov 10, 2018
92927ea
Finished cleaning up bokeh Scatter/Point plots, tests, docs
philippjfr Nov 11, 2018
637b8e1
Finished cleaning up bokeh Histogram plot, tests, doc
philippjfr Nov 11, 2018
a705574
Overhauled bokeh BarPlot code, tests, docs
philippjfr Nov 11, 2018
2c4709d
Finished off mpl PointPlot code, tests, docs
philippjfr Nov 11, 2018
15b769b
Finalized handling of SpikesPlot across backends
philippjfr Nov 11, 2018
dc3c5fd
Finalized style mapping for Spikes and Labels
philippjfr Nov 11, 2018
67d518a
Finalized style mapping support for VectorField
philippjfr Nov 11, 2018
4f73fbd
Finalized style mapping for ErrorBars
philippjfr Nov 11, 2018
b369251
Finalized CurvePlot and AreaPlot style mapping
philippjfr Nov 11, 2018
0f8a818
Various updates to examples
philippjfr Nov 12, 2018
8160286
Resolve tuple op specs
philippjfr Nov 12, 2018
98218c8
Fix for CompositeElementPlot
philippjfr Nov 12, 2018
4a6fa7a
Fixed bug in DataLinkCallback
philippjfr Nov 12, 2018
1d71f79
Fixed BoxWhiskerPlot bug
philippjfr Nov 12, 2018
232ac40
Added common function to ops
philippjfr Nov 15, 2018
87411d9
Various updates for Graph and stats elements
philippjfr Nov 17, 2018
2edbd80
Renamed op to dim
philippjfr Nov 17, 2018
0b15b45
Fixed import
philippjfr Nov 17, 2018
cae455d
Fixed flakes
philippjfr Nov 17, 2018
b840e21
BarPlot fixes
philippjfr Nov 17, 2018
dfc62ae
Fixed bokeh tests
philippjfr Nov 17, 2018
15230d1
Fixes for matplotlib tests
philippjfr Nov 17, 2018
d68c094
Fixed flake
philippjfr Nov 17, 2018
a436a8b
Made plotting imports consistent
philippjfr Nov 17, 2018
a514bb3
Fixed py2 handling of LooseVersion
philippjfr Nov 17, 2018
f00860c
Fixed LooseVersion
philippjfr Nov 17, 2018
b95c018
Added unit tests for updating matplotlib chart styles
philippjfr Nov 18, 2018
2cda953
Fixes for mpl Graph style mapping
philippjfr Nov 18, 2018
5725053
Fixes for fill/line color and TriMesh plotting
philippjfr Nov 18, 2018
f4ede90
Refactored code to check whether dim transform applies
philippjfr Nov 18, 2018
82808f6
Added support for normalizing dim transforms
philippjfr Nov 19, 2018
8144864
Better handling for filled and non-filled glyphs
philippjfr Nov 19, 2018
8f89a0e
Handle alpha validation
philippjfr Nov 19, 2018
5868705
Added unit tests for stats elements
philippjfr Nov 19, 2018
c30e29e
Small fix
philippjfr Nov 19, 2018
61e6419
Added HexTilePlot unit tests
philippjfr Nov 19, 2018
5828804
Fixed flakes
philippjfr Nov 19, 2018
e2700a1
Fixed unit tests
philippjfr Nov 19, 2018
47f65be
Added unit tests for contour and polygon plots
philippjfr Nov 19, 2018
4638c2b
Fixed issue in SankeyPlot
philippjfr Nov 19, 2018
040effa
Added docs to dim transforms
philippjfr Nov 19, 2018
67826db
Renamed ops to transform
philippjfr Nov 19, 2018
122d8c0
Added dim transform unit tests
philippjfr Nov 19, 2018
daffaae
Removed support for dim tuple spec
philippjfr Nov 19, 2018
a5f4d46
Apply suggestions from code review
jbednar Nov 19, 2018
0a31fe4
Renamed apply_ops to apply_transforms
philippjfr Nov 19, 2018
3c224af
Renamed _no_op_styles
philippjfr Nov 19, 2018
6981eb9
Fixed flake
philippjfr Nov 19, 2018
43a2448
Fixed scalar dim transform normalization
philippjfr Nov 19, 2018
056a0b5
Renamed dim.eval to dim.apply
philippjfr Nov 20, 2018
14af370
Marked old plot options as deprecated
philippjfr Nov 20, 2018
c23aab1
Fixed handling of dim color mapping range lookup
philippjfr Nov 20, 2018
9973afb
Update holoviews/util/transform.py
jbednar Nov 20, 2018
c4c1a3f
Update holoviews/util/transform.py
jbednar Nov 20, 2018
0321029
Update holoviews/util/transform.py
jbednar Nov 20, 2018
4d167f5
Added matplotlib validator
philippjfr Nov 20, 2018
0fe9f8c
Fixed python2 issues
philippjfr Nov 20, 2018
d7a4595
Fixed flakes
philippjfr Nov 20, 2018
01fe7e0
Fixed bug in mpl validator
philippjfr Nov 20, 2018
5901768
Handle style transforms for ChordPlots
philippjfr Nov 20, 2018
7e0d7b3
Use unique_array utility throughout
philippjfr Nov 21, 2018
895cb65
Added dim key lookup utility
philippjfr Nov 21, 2018
79990f5
Fixed issue colormapping scalar styles
philippjfr Nov 21, 2018
cc371f1
Make normalization system compute factors
philippjfr Nov 21, 2018
f2053e5
Fixes for drawing Chord arcs
philippjfr Nov 21, 2018
9dfce9b
Fixed syntax error
philippjfr Nov 21, 2018
785c40a
Fixed factor sorting issues
philippjfr Nov 21, 2018
0680782
Fixed colorbars on PathPlot
philippjfr Nov 21, 2018
acd5f6f
Fixed flakes
philippjfr Nov 21, 2018
9fb6db8
Fixed color handling for Graphs
philippjfr Nov 21, 2018
f13a324
Renamed dim transform helper functions
philippjfr Nov 21, 2018
6c4262a
Updated HexTiles
philippjfr Nov 21, 2018
5740075
Add warning about size_index and scale transform on HexTilePlot
philippjfr Nov 21, 2018
523e3a1
Updated unit tests
philippjfr Nov 21, 2018
d047bc8
Fixed expansion of color/alpha options in bokeh
philippjfr Nov 21, 2018
bdf2598
Normalize graph edges correctly
philippjfr Nov 21, 2018
1663316
Fixed flake
philippjfr Nov 21, 2018
2b80840
Fix for ChordPlot node style
philippjfr Nov 21, 2018
655fcc3
Fixed a number of examples
philippjfr Nov 21, 2018
ebb716a
Added utility to handle matplotlib style groups
philippjfr Nov 21, 2018
c5f25cc
Fixed flake
philippjfr Nov 21, 2018
00f9de6
Fixed small bug
philippjfr Nov 21, 2018
43f4aca
Updated SankeyPlot
philippjfr Nov 22, 2018
a55529e
Added dim.str transform
philippjfr Nov 22, 2018
ec0487c
Further Sankey fixes
philippjfr Nov 22, 2018
3086224
Updated nyc_airport_routes
philippjfr Nov 22, 2018
f5f5c15
Fixed issue in VectorField
philippjfr Nov 22, 2018
d71c656
Fixed stray tuple dim format in examples
philippjfr Nov 22, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/gallery/demos/bokeh/autompg_histogram.ipynb
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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')"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a stray instance of the tuple format...

]
}
],
Expand Down
4 changes: 2 additions & 2 deletions examples/gallery/demos/bokeh/bars_economic.ipynb
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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')"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And another tuple...

]
}
],
Expand Down
4 changes: 2 additions & 2 deletions examples/gallery/demos/bokeh/choropleth_data_link.ipynb
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
2 changes: 1 addition & 1 deletion examples/gallery/demos/bokeh/quiver_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts VectorField [width=500 color_index=3 size_index=3 pivot='tip'] Points (color='black')\n",
"%%opts VectorField [width=500 size_index=3 pivot='tip'] (color='Magnitude') Points (color='black')\n",
"hv.VectorField((xs, ys, angle, mag), label=\"pivot='tip'; scales with x view\") * hv.Points((X.flat, Y.flat))"
]
}
Expand Down
2 changes: 1 addition & 1 deletion examples/gallery/demos/matplotlib/dropdown_economic.ipynb
Original file line number Diff line number Diff line change
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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think 'dim' turns out much more readable than 'op' here; I can immediately see that the size will be set to 10 times the unemployment value. Nice.

"%%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
Original file line number Diff line number Diff line change
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 size_index=3] (color='Magnitude' pivot='tip') Points (color='black' s=5)\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be deprecating size_index now?

Suggested change
"%%opts VectorField [aspect=1.5 fig_size=200 size_index=3] (color='Magnitude' pivot='tip') Points (color='black' s=5)\n",
"%%opts VectorField [aspect=1.5 fig_size=200] (size='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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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, this can be useful for plotting neuron spike trains or other events. 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:"
philippjfr marked this conversation as resolved.
Show resolved Hide resolved
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion examples/reference/elements/bokeh/TriMesh.ipynb
Original file line number Diff line number Diff line change
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
6 changes: 3 additions & 3 deletions examples/reference/elements/bokeh/VectorField.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts VectorField [size_index=3] VectorField.A [color_index=2] VectorField.M [color_index=3]\n",
"%%opts VectorField [size_index=3] VectorField.A (color='Angle') VectorField.M (color='Magnitude')\n",
"hv.VectorField(vector_data, group='A') + hv.VectorField(vector_data, group='M')"
]
},
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 [size_index=3 rescale_lengths=False] (scale=4, color='Angle')\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"%%opts VectorField [size_index=3 rescale_lengths=False] (scale=4, color='Angle')\n",
"%%opts VectorField [rescale_lengths=False] (size='Magnitude' scale=4 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 size_index=3 pivot='tip'] (cmap='fire' scale=0.8 color='Magnitude') Points (color='black' size=1)\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"%%opts VectorField [width=500 size_index=3 pivot='tip'] (cmap='fire' scale=0.8 color='Magnitude') Points (color='black' size=1)\n",
"%%opts VectorField [width=500 pivot='tip'] (size='Magnitude' cmap='fire' scale=0.8 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
Original file line number Diff line number Diff line change
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`` op to bin the 'y' values into positive and negative values and map those to a 'blue' and 'red' ``fill_color``:"
philippjfr marked this conversation as resolved.
Show resolved Hide resolved
]
},
{
"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
6 changes: 3 additions & 3 deletions examples/reference/elements/matplotlib/Spikes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"When supplying a second dimension to the ``Spikes`` element as a value dimensions, 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, this can be useful for plotting neuron spike trains or other events. 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:"
philippjfr marked this conversation as resolved.
Show resolved Hide resolved
]
},
{
Expand Down
Loading