Skip to content

Commit

Permalink
Added BoxWhisker Example to Elements Tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Dec 19, 2015
1 parent d4d15ba commit 4c860d2
Showing 1 changed file with 67 additions and 1 deletion.
68 changes: 67 additions & 1 deletion doc/Tutorials/Elements.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
" <dt>[``Spread``](#Spread)</dt><dd>Just like ErrorBars, Spread is a collection of x-/y-coordinates with associated symmetric or asymmetric errors.</dd>\n",
" <dt>[``Bars``](#Bars)</dt><dd>Data collected and binned into categories.</dd>\n",
" <dt>[``Histogram``](#Histogram)</dt><dd>Data collected and binned in a continuous space using specified bin edges.</dd>\n",
" <dt>[``BoxWhisker``](#BoxWhisker)</dt><dd>Distributions of data varying by 0-N key dimensions.</dd>\n",
" <dt>[``Scatter``](#Scatter)</dt><dd>Discontinuous collection of points indexed over a single dimension.</dd>\n",
" <dt>[``Points``](#Points)</dt><dd>Discontinuous collection of points indexed over two dimensions.</dd>\n",
" <dt>[``VectorField``](#VectorField)</dt><dd>Cyclic variable (and optional auxiliary data) distributed over two-dimensional space.</dd>\n",
Expand Down Expand Up @@ -327,6 +328,71 @@
" kdims=['Group', 'Category', 'Stack'], vdims=['Count'])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### ``BoxWhisker`` <a id='BoxWhisker'></a>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The ``BoxWhisker`` Element allows representing distribution of data varying by 0-N key dimensions. To represent the distribution of a single variable we can create a BoxWhisker Element with no key dimensions and a single value dimension:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"hv.BoxWhisker(np.random.randn(200), kdims=[], vdims=['Value'])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"By adding a key dimension we can compare multiple distributions. Since the variables are randomly assigned we sort the Element first."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"hv.BoxWhisker((np.random.randint(0, 10, 200), np.random.randn(200)),\n",
" kdims=['Variable'], vdims=['Value']).sort()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"BoxWhisker Elements support any number of dimensions and may also be inverted. To style the boxes and whiskers supply boxprops, whiskerprops and flierprops."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%%opts BoxWhisker [fig_size=200 invert_axes=True] (boxprops=dict(color='gray') whiskerprops=dict(color='indianred'))\n",
"groups = [chr(65+g) for g in np.random.randint(0, 3, 200)]\n",
"hv.BoxWhisker((groups, np.random.randint(0, 5, 200), np.random.randn(200)),\n",
" kdims=['Group', 'Category'], vdims=['Value']).sort()"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -1390,7 +1456,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.10"
"version": "2.7.11"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 4c860d2

Please sign in to comment.