Skip to content

Commit

Permalink
Added twin axis section to customizing plots user guide
Browse files Browse the repository at this point in the history
  • Loading branch information
jlstevens committed Jul 20, 2023
1 parent b48f555 commit 8f94a0e
Showing 1 changed file with 84 additions and 1 deletion.
85 changes: 84 additions & 1 deletion examples/user_guide/Customizing_Plots.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
" - [Inverting axes](#inverting-axes): Flipping the x-/y-axes and inverting an axis\n",
" - [Axis labels](#axis-labels): Setting axis labels using dimensions and options\n",
" - [Axis ranges](#axis-ranges): Controlling axes ranges using dimensions, padding and options\n",
" - [Axis ticks](#axis-ticks): Controlling axis tick locations, labels and formatting"
" - [Axis ticks](#axis-ticks): Controlling axis tick locations, labels and formatting\n",
" - [Twin axes](#twin-axes): Enabling twin axes"
]
},
{
Expand Down Expand Up @@ -689,6 +690,88 @@
"source": [
"bars.opts(xrotation=45)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Twin axes\n",
"*(Available in HoloViews > 1.17)*\n",
"\n",
"HoloViews now supports displaying overlays containing two different value dimensions as twin axes for chart elements. To maintain backwards compatibility, this feature is only enabled by setting the `multi_y=True` option on the overlay:\n",
"\n",
"To illustrate, here is an overlay containing three curves with two value dimensions ('A' and 'B'). The following shows the default, backwards compatible behavior:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"overlay = hv.Curve([1, 2, 3], vdims=['A']) * hv.Curve([2, 3, 4], vdims=['A']) * hv.Curve([3, 2, 1], vdims=['B'])\n",
"overlay"
]
},
{
"cell_type": "markdown",
"metadata": {
"tags": []
},
"source": [
"Additional value dimensions do map to additional axes but be aware that support of multi axes beyond twin axes is currently considered experimental.\n",
"\n",
"#### Setting `multi_y=True`\n",
"\n",
"We can now enable twin axes by setting `multi_y=True` on the overlay:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"overlay.opts(multi_y=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The first value dimension is mapped to the left-hand axis and the second value dimension maps to the right axis. Note that the two axes are individually zoomable by hovering over them and using the Bokeh wheelzoom tool.\n",
"\n",
"\n",
"#### Supported `multi_y` options\n",
"\n",
"When `multi_y` is enabled, you can set individual axis options on the elements of the overlay.\n",
"\n",
"In this example, the left axis uses the default options while the right axis is an inverted, autoranged, log axis with a set `ylim`:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"(hv.Curve([1, 2, 3], vdims=['A']) * hv.Curve([2, 3, 4], vdims=['B']).opts(autorange='y', invert_yaxis=True, logy=True, ylim=(1,10))).opts(multi_y=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Supported options for customizing individual axes are `apply_ranges`, `autorange='y'`, `invert_yaxis`, `logy` and `ylim`.\n",
"\n",
"Note that as of HoloViews 1.17.0, `multi_y` does not have streaming plot support"
]
}
],
"metadata": {
Expand Down

0 comments on commit 8f94a0e

Please sign in to comment.