diff --git a/examples/environment.yml b/examples/environment.yml index 7ef56983..93fe1b7e 100644 --- a/examples/environment.yml +++ b/examples/environment.yml @@ -1,33 +1,25 @@ -# file created by pyctdev: -# /cio/mc3/bin/doit env_export2 --env-name-again=pyviz --env-file=examples/environment.yml --package-name=holoviz -c holoviz/label/dev -c defaults --pin-deps - -name: holoviz +name: holoviz-tutorial channels: - - pyviz/label/dev + - holoviz - defaults dependencies: - - bokeh ==1.0.0dev6 - - cartopy + - bokeh ==1.2.0 - cffi - - dask ==0.18.2 - - datashader ==0.6.8 + - dask ==1.2.2 + - datashader ==0.7.0 - fastparquet - - geopandas - - geoviews ==1.5.4a6 - - holoviews ==1.11.0a4 - - hvplot ==0.2.1 + - holoviews ==1.12.3 + - hvplot ==0.4.0 - ipython ==5.* - - ipywidgets ==7.* - - jupyter + - ipywidgets + - matplotlib - netcdf4 - networkx - - notebook >=5.5 - - numpy ==1.14.5 - - pandas ==0.23.4 - - panel ==0.1.0a3 - - param ==1.8.0a2 - - parambokeh ==0.2.3 - - paramnb ==2.0.4 + - notebook + - numpy ==1.16.4 + - pandas ==0.24.0 + - panel ==0.6.0 + - param ==1.9.1 - phantomjs - pyct - python ==3.6.* @@ -35,6 +27,5 @@ dependencies: - rise - scikit-image - selenium - - streamz ==0.3.0 - - tornado ==4.5.3 - - xarray ==0.10.3 + - streamz ==0.5.0 + - xarray ==0.12.1A diff --git a/examples/tutorial/04_Using_.plot.ipynb b/examples/tutorial/04_Using_.plot.ipynb index 4ac2e382..1a09ea74 100644 --- a/examples/tutorial/04_Using_.plot.ipynb +++ b/examples/tutorial/04_Using_.plot.ipynb @@ -143,9 +143,16 @@ "source": [ "Here if you hover over any of the datapoints, you can see some information about it, which makes the hvPlot output much more useful than the original static PNG. You can also pan and zoom to focus on any particular region of the data of interest.\n", "\n", - "You might have noticed that many of the dots in the scatter that we've just created lie on top of one another. This is called [\"overplotting\"](http://datashader.org/user_guide/1_Plotting_Pitfalls.html#1.-Overplotting) and can be avoided in a variety of ways, such as by making the dots slightly transparent, or binning the data. These approaches have the downside of introducing bias because you need to choose the alpha or the edges of the bins, and in order to do that, you have to make assumptions about the data. For an initial exploration of a new dataset, it's much safer if you can just *see* the data, before you impose any assumptions about its form or structure. \n", + "You might have noticed that many of the dots in the scatter that we've just created lie on top of one another. This is called [\"overplotting\"](http://datashader.org/user_guide/1_Plotting_Pitfalls.html#1.-Overplotting) and can be avoided in a variety of ways, such as by making the dots slightly transparent, or binning the data. These approaches have the downside of introducing bias because you need to choose the alpha or the edges of the bins, and in order to do that, you have to make assumptions about the data. For an initial exploration of a new dataset, it's much safer if you can just *see* the data, before you impose any assumptions about its form or structure. \n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Exercise\n", "\n", - "Instead of these traditional approaches, we can use [Datashader](datashader.org), which aggregates data into each pixel without any arbitrary parameter settings. In `hvplot` we can activate this capability by setting `datashade=True`." + "Try changing the alpha (try .1) on the plot above to see the effect of this approach" ] }, { @@ -153,8 +160,29 @@ "execution_count": null, "metadata": {}, "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, "source": [ - "### Exercise: Try changing the alpha (try .1) on the plot above to see the effect of this approach, or create a hexbin plot." + "Try creating a `hexbin` plot." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Datashader\n", + "\n", + "Instead of these traditional approaches, we can use [Datashader](datashader.org), which aggregates data into each pixel without any arbitrary parameter settings. In `hvplot` we can activate this capability by setting `datashade=True`." ] }, { @@ -207,20 +235,28 @@ " - NetworkX : Graph (network graphs)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Exercise\n", + "\n", + "If you are brave and don't mind refreshing your browser tab if it dies, create a scatter without setting datashade=True." + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], - "source": [ - "### Exercise: If you are brave and don't mind refreshing your browser tab if it dies, \n", - "### create a scatter without setting datashade=True." - ] + "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ + "### A Note on `points`\n", + "\n", "As a final note, we should really use `hvplot.points` instead of `hvplot.scatter` in this instance. The former does not exist in the standard pandas `.plot` API which is why we use `hvplot.scatter` up until now.\n", "\n", "The reason scatter is inappropriate is that it implies that the y-axis (latitude) is a *dependent variable* with respect to the x-axis (latitude). In reality, this is not the case as earthquakes can happen at anywhere on the Earth's two-dimensional surface. For this reason, it is best to use `hvplot.points` to present earthquake locations as will be explained further in the next notebook." @@ -291,14 +327,21 @@ "cleaned_df.hvplot.hist(y='mag', bin_range=(0,10), bins=50)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Exercise\n", + "\n", + "Create a kernel density estimate (kde) plot of magnitude." + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], - "source": [ - "### Exercise: Create a kernel density estimate (kde) plot of magnitude." - ] + "source": [] }, { "cell_type": "markdown", @@ -363,19 +406,27 @@ "**NOTE:** Click on the legend to turn off certain categories and see what is behind them." ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Exercise\n", + "\n", + "Add `subplots=True` and `width=300` to see the different classes side-by-side. The y-axis will be linked, so try zooming." + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], - "source": [ - "### Exercise: Add subplots=True and width=300 to see the different classes side-by-side. The y-axis will be linked, so try zooming." - ] + "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ + "### Grouping\n", "To use a widget to toggle between classes, use the `groupby` option, here in a bivariate plot:" ] }, @@ -392,8 +443,6 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Classifying by magnitude\n", - "\n", "In addition to classifying by depth, we can classify by magnitude.\n", "\n", "| Class | Magnitude | \n", diff --git a/examples/tutorial/05_Composing_Holoviews_Plots.ipynb b/examples/tutorial/05_Composing_Holoviews_Plots.ipynb index 73258147..a610231d 100644 --- a/examples/tutorial/05_Composing_Holoviews_Plots.ipynb +++ b/examples/tutorial/05_Composing_Holoviews_Plots.ipynb @@ -113,15 +113,6 @@ "This is HoloViews notation for saying that the plot is a `Curve` element with `time` as the key dimension (`kdim`) and `count` as the value dimension (`vdim`). HoloViews will be discussed in more detail in the [next section](./06_Custom_Interactivity.ipynb)." ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "### Exercise: Use tab completion to explore monthly_count_plot. Try .data or .table()" - ] - }, { "cell_type": "code", "execution_count": null, @@ -165,15 +156,42 @@ "Interestingly, there are three clear peaks in the monthy counts, and two of them correspond to sudden dips in the mean magnitude, while the third corresponds to a peak in the mean magnitude." ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Exercise\n", + "\n", + "Use tab completion to explore `monthly_count_plot`. \n", + "\n", + "
Hint
\n", + "\n", + "Try .data or .table()\n", + "\n", + "
" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, "source": [ - "### Exercise: Zoom in and out to explore the linking between the plots." + "Zoom in and out to explore the linking between the plots." ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "markdown", "metadata": {}, @@ -323,19 +341,46 @@ "print(high_mag_points)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Exercise\n", + "\n", + "Compare this `Points` printed representation to the `Scatter` printed representation and note the differences in how the dimensions are grouped together." + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, "source": [ - "### Exercise: Compare this Points printed representation to the Scatter printed representation\n", - "### and note the differences in how the dimensions are grouped together.\n", + "Use the colorcet plotting module `swatches(group='linear')` to choose a different colormap. \n", + "\n", + "\n", + "
Hint
\n", "\n", - "### Exercise: Use the colorcet plotting module swatches(group='linear')\n", - "### - import from colorcet.plotting - to choose a different colormap. " + "```python\n", + "from colorcet.plotting import swatches\n", + "swatches(group='linear')\n", + "```\n", + "\n", + "
" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "markdown", "metadata": {}, @@ -408,21 +453,35 @@ " title='Earthquakes with magnitude >= 7')" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Exercise\n", + "\n", + "Import and use different tiles. \n", + "\n", + "\n", + "
Hint
\n", + "\n", + "EsriImagery or Wikipedia.\n", + "\n", + "
\n" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], - "source": [ - "### Exercise: Import and use different tiles. Try EsriImagery or Wikipedia." - ] + "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Overlay with a raster\n", - "That base map is helpful for orienting ourselves, but it isn't really adding too much new information. We might instead like to overlay the earthquakes on a map of global population. We'll start by reading in a raster of global population, to see how the events might affect people. We'll use [xarray](https://xarray.pydata.org) to load this multidimensional raster data file, as such formats are not handled well by Pandas:|" + "That base map is helpful for orienting ourselves, but it isn't really adding too much new information. We might instead like to overlay the earthquakes on a map of global population. We'll start by reading in a raster of global population, to see how the events might affect people. We'll use [xarray](https://xarray.pydata.org) to load this multidimensional raster data file, as such formats are not handled well by Pandas:" ] }, { @@ -498,19 +557,28 @@ "print(rasterized_pop)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Exercise\n", + "\n", + "Use `.last` to inspect the last image from the `DynamicMap`. Zoom into the plot above and inspect `.last` again." + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], - "source": [ - "### Exercise: Use .last to inspect the last image from the DynamicMap. Zoom into the plot above and inspect .last again." - ] + "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ + "### Putting it together\n", + "\n", "Now we can clean up the styling on this map because the color scale and the color map make it very hard to see what's going on. We'll also overlay this with the earthquakes." ] },