Skip to content

Commit

Permalink
Merge c05ec76 into 55a94e9
Browse files Browse the repository at this point in the history
  • Loading branch information
jlstevens committed Nov 29, 2018
2 parents 55a94e9 + c05ec76 commit fd3f579
Show file tree
Hide file tree
Showing 44 changed files with 521 additions and 346 deletions.
6 changes: 4 additions & 2 deletions examples/gallery/demos/bokeh/area_chart.ipynb
Expand Up @@ -19,6 +19,7 @@
"source": [
"import numpy as np\n",
"import holoviews as hv\n",
"from holoviews import opts\n",
"hv.extension('bokeh')"
]
},
Expand Down Expand Up @@ -59,8 +60,9 @@
"metadata": {},
"outputs": [],
"source": [
"overlay = (python * pypy * jython).options('Area', fill_alpha=0.5)\n",
"overlay.relabel(\"Area Chart\") + hv.Area.stack(overlay).relabel(\"Stacked Area Chart\")"
"overlay = (python * pypy * jython)\n",
"layout = overlay.relabel(\"Area Chart\") + hv.Area.stack(overlay).relabel(\"Stacked Area Chart\")\n",
"layout.options(opts.Area(fill_alpha=0.5))"
]
}
],
Expand Down
7 changes: 4 additions & 3 deletions examples/gallery/demos/bokeh/autompg_histogram.ipynb
Expand Up @@ -16,7 +16,8 @@
"outputs": [],
"source": [
"import holoviews as hv\n",
"hv.extension('bokeh','matplotlib')"
"from holoviews import opts\n",
"hv.extension('bokeh')"
]
},
{
Expand Down Expand Up @@ -52,8 +53,8 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Histogram (alpha=0.9) [width=600]\n",
"autompg_ds.hist(dimension='mpg', groupby='cyl', bin_range=(9, 46), bins=40, adjoin=False)"
"hist = autompg_ds.hist(dimension='mpg', groupby='cyl', bin_range=(9, 46), bins=40, adjoin=False)\n",
"hist.options(opts.Histogram(alpha=0.9, width=600))"
]
}
],
Expand Down
38 changes: 22 additions & 16 deletions examples/gallery/demos/bokeh/bachelors_degrees_by_gender.ipynb
Expand Up @@ -18,6 +18,7 @@
"outputs": [],
"source": [
"import holoviews as hv\n",
"from holoviews import opts\n",
"hv.extension('bokeh', 'matplotlib')"
]
},
Expand All @@ -28,6 +29,17 @@
"## Define data"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This example uses the matplotlib sample data that conda users can fetch using:\n",
"\n",
"```\n",
"conda install -c conda-forge mpl_sample_data\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -70,11 +82,11 @@
" return '%d%' % x\n",
"\n",
"# Define the value dimensions\n",
"vdim = hv.Dimension('conferred', value_format=percent_format, range=(0, 90))\n",
"vdim = hv.Dimension('conferred', range=(0, 90))\n",
"\n",
"# Define the dataset\n",
"ds = hv.Dataset(df, vdims=vdim)\n",
"curves = ds.to(hv.Curve, 'Year', groupby='Degree').overlay()\n",
"curves = ds.to(hv.Curve, 'Year', groupby='Degree').overlay().redim(Year=dict(range=(1970, 2030)))\n",
"\n",
"# Define a function to get the text annotations\n",
"max_year = ds['Year'].max()\n",
Expand All @@ -98,22 +110,16 @@
"metadata": {},
"outputs": [],
"source": [
"def grid_cb(plot, element):\n",
" plot = plot.handles['plot']\n",
" plot.xgrid.visible=False\n",
" plot.ygrid.grid_line_dash = [6, 4]\n",
" plot.ygrid.grid_line_width = 3\n",
" plot.grid.bounds = (1970, 2010)\n",
"overlay = (curves * labels).relabel(title)\n",
"\n",
"# Define some custom options for bokeh\n",
"options = hv.Store.options(backend='bokeh')\n",
"options.NdOverlay = hv.Options('plot', batched=False)\n",
"options.Curve = hv.Options('plot', show_frame=False, labelled=[], tools=['hover'], hooks=[grid_cb],\n",
" height=900, width=900, show_legend=False, xticks=[1970, 1980, 1990, 2000, 2010])\n",
"options.Curve = hv.Options('style', color=hv.Cycle(values=color_sequence), line_width=2)\n",
"gridstyle = {'grid_line_dash': [6, 4], 'grid_line_width': 3, 'grid_bounds': (0, 100)}\n",
"\n",
"(curves.redim(Year=dict(range=(1970, 2030))) *\n",
" labels.options(color_index='Degree', cmap=color_sequence, text_align='left')).relabel(title)"
"overlay.options(\n",
" opts.Curve(show_frame=False, labelled=[], tools=['hover'],\n",
" height=900, width=900, show_legend=False, xticks=[1970, 1980, 1990, 2000, 2010],\n",
" color=hv.Cycle(values=color_sequence), line_width=2, show_grid=True, yformatter='%d%%'),\n",
" opts.Labels(text_color='Degree', cmap=color_sequence, text_align='left'),\n",
" opts.NdOverlay(batched=False, gridstyle=gridstyle))"
]
}
],
Expand Down
8 changes: 5 additions & 3 deletions examples/gallery/demos/bokeh/bars_economic.ipynb
Expand Up @@ -17,6 +17,7 @@
"source": [
"import pandas as pd\n",
"import holoviews as hv\n",
"from holoviews import opts\n",
"hv.extension('bokeh','matplotlib')"
]
},
Expand Down Expand Up @@ -53,9 +54,10 @@
"metadata": {},
"outputs": [],
"source": [
"%%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', [])"
"bars = macro.to.bars(['Year', 'Country'], 'Trade', [])\n",
"bars.options(\n",
" opts.Bars(color=hv.Cycle('Category20'), show_legend=False, stacked=True, \n",
" tools=['hover'], width=600, xrotation=90))"
]
}
],
Expand Down
9 changes: 6 additions & 3 deletions examples/gallery/demos/bokeh/box_draw_roi_editor.ipynb
Expand Up @@ -8,6 +8,7 @@
"source": [
"import numpy as np\n",
"import holoviews as hv\n",
"from holoviews import opts\n",
"from holoviews import streams\n",
"hv.extension('bokeh')"
]
Expand Down Expand Up @@ -75,9 +76,11 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Curve [width=400] {+framewise} NdOverlay [legend_limit=0] \n",
"%%opts Polygons (fill_alpha=0.2 line_color='white') VLine (color='black')\n",
"ds.to(hv.Image, ['x', 'y'], dynamic=True) * polys + dmap * hlines"
"im = ds.to(hv.Image, ['x', 'y'], dynamic=True)\n",
"(im * polys + dmap * hlines).options(\n",
" opts.Curve(width=400, framewise=True), \n",
" opts.Polygons(fill_alpha=0.2, line_color='white'), \n",
" opts.VLine(color='black'))"
]
},
{
Expand Down
9 changes: 5 additions & 4 deletions examples/gallery/demos/bokeh/choropleth_data_link.ipynb
Expand Up @@ -9,6 +9,7 @@
"import numpy as np\n",
"import pandas as pd\n",
"import holoviews as hv\n",
"from holoviews import opts\n",
"\n",
"from holoviews.plotting.links import DataLink\n",
"\n",
Expand Down Expand Up @@ -70,13 +71,13 @@
"metadata": {},
"outputs": [],
"source": [
"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",
"\n",
"choropleth + table"
"(choropleth + table).options(\n",
" opts.Table(height=428),\n",
" opts.Polygons(width=500, height=500, tools=['hover', 'tap'], xaxis=None, \n",
" yaxis=None, color_index='Unemployment'), clone=False)"
]
}
],
Expand Down
14 changes: 6 additions & 8 deletions examples/gallery/demos/bokeh/directed_airline_routes.ipynb
Expand Up @@ -18,6 +18,7 @@
"import numpy as np\n",
"import networkx as nx\n",
"import holoviews as hv\n",
"from holoviews import opts\n",
"\n",
"from holoviews.element.graphs import layout_nodes\n",
"from bokeh.sampledata.airport_routes import routes, airports\n",
Expand Down Expand Up @@ -63,14 +64,11 @@
"metadata": {},
"outputs": [],
"source": [
"as_graph.options(\n",
" directed=True, node_size=8, padding=0.1, bgcolor='gray', xaxis=None, yaxis=None,\n",
" edge_line_color='white', edge_line_width=1, width=800, height=800, arrowhead_length=0.01,\n",
" node_fill_color='white', node_nonselection_fill_color='black'\n",
") *\\\n",
"labels.options(\n",
" xoffset=-0.04, yoffset=0.03, text_font_size='10pt'\n",
")"
"(as_graph * labels).options(\n",
" opts.Graph(directed=True, node_size=8, padding=0.1, bgcolor='gray', xaxis=None, yaxis=None,\n",
" edge_line_color='white', edge_line_width=1, width=800, height=800, arrowhead_length=0.01,\n",
" node_fill_color='white', node_nonselection_fill_color='black'),\n",
" opts.Labels(xoffset=-0.04, yoffset=0.03, text_font_size='10pt'))"
]
}
],
Expand Down
12 changes: 5 additions & 7 deletions examples/gallery/demos/bokeh/dot_example.ipynb
Expand Up @@ -14,6 +14,7 @@
"outputs": [],
"source": [
"import holoviews as hv\n",
"from holoviews import opts\n",
"hv.extension('bokeh')"
]
},
Expand Down Expand Up @@ -54,13 +55,10 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Layout [shared_axes=False]\n",
"\n",
"spike_plot = dict(labelled=[], invert_axes=True, color_index=None)\n",
"spike_style = dict(color='green', line_width=4)\n",
"scatter_style = dict(size=15, fill_color=\"orange\", line_color=\"green\")\n",
"\n",
"heatmap + spikes(plot=spike_plot, style=spike_style) * scatter(style=scatter_style)"
"(heatmap + spikes * scatter).options(\n",
" opts.Scatter(size=15, fill_color=\"orange\", line_color=\"green\"),\n",
" opts.Spikes(color='green', line_width=4, labelled=[], invert_axes=True, color_index=None),\n",
" opts.Layout(shared_axes=False))"
]
}
],
Expand Down
8 changes: 5 additions & 3 deletions examples/gallery/demos/bokeh/dragon_curve.ipynb
Expand Up @@ -17,6 +17,7 @@
"outputs": [],
"source": [
"import holoviews as hv\n",
"from holoviews import opts\n",
"import numpy as np\n",
"hv.extension('bokeh')"
]
Expand Down Expand Up @@ -107,12 +108,13 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Path {+framewise} [xaxis=None yaxis=None title_format='' padding=0.1] (color='black' line_width=1)\n",
"\n",
"hmap = hv.HoloMap(kdims='Iteration')\n",
"for i in range(7,17):\n",
" hmap[i] = DragonCurve(-200, 0, i).path\n",
"hmap"
"\n",
"hmap.options(\n",
" opts.Path(axiswise=False, color='black', framewise=True, line_width=1, \n",
" padding=0.1, title_format='', xaxis=None, yaxis=None))"
]
}
],
Expand Down
13 changes: 8 additions & 5 deletions examples/gallery/demos/bokeh/dropdown_economic.ipynb
Expand Up @@ -17,6 +17,7 @@
"source": [
"import pandas as pd\n",
"import holoviews as hv\n",
"from holoviews import opts, dim\n",
"hv.extension('bokeh')"
]
},
Expand Down Expand Up @@ -53,15 +54,17 @@
"metadata": {},
"outputs": [],
"source": [
"%%opts Overlay [width=700 height=400 show_frame=False]\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",
"gdp_unem_scatter = macro.to.scatter('Year', ['GDP Growth', 'Unemployment'])\n",
"annotations = hv.Arrow(1973, 8, 'Oil Crisis', 'v') * hv.Arrow(1975, 6, 'Stagflation', 'v') *\\\n",
"hv.Arrow(1979, 8, 'Energy Crisis', 'v') * hv.Arrow(1981.9, 5, 'Early Eighties\\n Recession', 'v')\n",
"gdp_curves * gdp_unem_scatter* annotations"
"\n",
"(gdp_curves * gdp_unem_scatter* annotations).options(\n",
" opts.Curve(color='k'), \n",
" opts.Scatter(cmap='Blues', color='Unemployment', \n",
" line_color='k', size=dim('Unemployment')*1.5),\n",
" opts.Text(text_font_size='13px'),\n",
" opts.Overlay(height=400, show_frame=False, width=700))"
]
}
],
Expand Down
4 changes: 2 additions & 2 deletions examples/gallery/demos/bokeh/emoji_tsne.ipynb
Expand Up @@ -32,7 +32,7 @@
"outputs": [],
"source": [
"emoji_df = pd.read_csv('../../../assets/emoji_embeddings.csv', index_col=0)\n",
"emojis = hv.Labels(emoji_df, label='Emoji t-SNE Embeddings')"
"emojis = hv.Labels(emoji_df, label='Emoji t-SNE Embeddings').redim.range(x=(-30, 20), y=(-20, 20))"
]
},
{
Expand All @@ -48,7 +48,7 @@
"metadata": {},
"outputs": [],
"source": [
"emojis.options(width=1000, height=800, xaxis=None, yaxis=None).redim.range(x=(-30, 20), y=(-20, 20))"
"emojis.options(width=1000, height=800, xaxis=None, yaxis=None)"
]
}
],
Expand Down
3 changes: 2 additions & 1 deletion examples/gallery/demos/bokeh/energy_sankey.ipynb
Expand Up @@ -42,7 +42,8 @@
"metadata": {},
"outputs": [],
"source": [
"hv.Sankey(edges, label='Energy Diagram').options(label_position='left', edge_color='target', node_color='index', cmap='tab20')"
"sankey = hv.Sankey(edges, label='Energy Diagram')\n",
"sankey.options(label_position='left', edge_color='target', node_color='index', cmap='tab20')"
]
}
],
Expand Down
8 changes: 6 additions & 2 deletions examples/gallery/demos/bokeh/hextile_movie_ratings.ipynb
Expand Up @@ -8,6 +8,7 @@
"source": [
"import pandas as pd\n",
"import holoviews as hv\n",
"from holoviews import opts\n",
"hv.extension('bokeh')"
]
},
Expand All @@ -32,7 +33,8 @@
"movies = pd.read_sql('SELECT userRating, imdbRating FROM omdb, tomatoes WHERE omdb.ID = tomatoes.ID', conn)\n",
"\n",
"# Declare element\n",
"hextiles = hv.HexTiles(movies, [('userRating', 'Tomato User Rating'), ('imdbRating', 'IMDb Rating')], [])"
"hextiles = hv.HexTiles(movies, [('userRating', 'Tomato User Rating'), ('imdbRating', 'IMDb Rating')], [])\n",
"bivariate = hv.Bivariate(hextiles)"
]
},
{
Expand All @@ -48,7 +50,9 @@
"metadata": {},
"outputs": [],
"source": [
"hextiles.options(width=500, height=500, min_count=0) * hv.Bivariate(hextiles).options(show_legend=False)"
"(hextiles * bivariate).options(\n",
" opts.Bivariate(show_legend=False),\n",
" opts.HexTiles(width=500, height=500, min_count=0))"
]
}
],
Expand Down
7 changes: 6 additions & 1 deletion examples/gallery/demos/bokeh/histogram_example.ipynb
Expand Up @@ -21,6 +21,7 @@
"import scipy\n",
"import scipy.special\n",
"import holoviews as hv\n",
"from holoviews import opts\n",
"hv.extension('bokeh')"
]
},
Expand Down Expand Up @@ -120,7 +121,11 @@
"options = {'Histogram': dict(fill_color=\"#036564\", axiswise=True, height=350, width=350, bgcolor=\"#E8DDCB\"),\n",
" 'Curve': dict(axiswise=True), 'Layout': dict(shared_axes=False)}\n",
"\n",
"(norm + lognorm + gamma + beta + weibull).options(options).cols(2)"
"layout = (norm + lognorm + gamma + beta + weibull).cols(2)\n",
"layout.options(\n",
" opts.Curve(axiswise=True),\n",
" opts.Histogram(fill_color=\"#036564\", axiswise=True, height=350, width=350, bgcolor=\"#E8DDCB\"),\n",
" opts.Layout(shared_axes=False))"
]
}
],
Expand Down
5 changes: 3 additions & 2 deletions examples/gallery/demos/bokeh/image_range_tool.ipynb
Expand Up @@ -11,6 +11,7 @@
"import numpy as np\n",
"import pandas as pd\n",
"import holoviews as hv\n",
"from holoviews import opts\n",
"from holoviews.plotting.links import RangeToolLink\n",
"\n",
"hv.extension('bokeh')"
Expand Down Expand Up @@ -84,11 +85,11 @@
"source": [
"src = mbset_image.options(width=300, height=300)\n",
"tgt = mbset_image.options(width=500, height=500, xaxis=None, yaxis=None)\n",
"\n",
"# Declare a RangeToolLink between the x- and y-axes of the two plots\n",
"RangeToolLink(src, tgt, axes=['x', 'y'])\n",
"\n",
"(tgt + src).options(shared_axes=False, clone=False)"
"(tgt + src).options(\n",
" opts.Layout(shared_axes=False), clone=False)"
]
}
],
Expand Down

0 comments on commit fd3f579

Please sign in to comment.