Skip to content

Commit

Permalink
Merge 6c567a6 into 17ce0cc
Browse files Browse the repository at this point in the history
  • Loading branch information
maximlt committed Nov 18, 2021
2 parents 17ce0cc + 6c567a6 commit 9c0886e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 33 deletions.
2 changes: 1 addition & 1 deletion examples/user_guide/Geographic_Data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
"source": [
"Note that when displaying raster data in a projection other than the one in which the data is stored, it is more accurate to render it as a ``quadmesh`` rather than an ``image``. As you can see above, a QuadMesh will project each original bin or pixel into the correct non-rectangular shape determined by the projection, accurately showing the geographic extent covered by each sample. An Image, on the other hand, will always be rectangularly aligned in the 2D plane, which requires warping and resampling the data in a way that allows efficient display but loses accuracy at the pixel level. Unfortunately, rendering a large QuadMesh using Bokeh can be very slow, but there are two useful alternatives for datasets too large to be practical as native QuadMeshes.\n",
"\n",
"The first is using the ``datashade`` or ``rasterize`` options to regrid the data before rendering it, i.e., rendering the data on the backend and then sending a more efficient image-based representation to the browser. One thing to note when using these operations is that it may be necessary to project the data **before** rasterizing it, e.g. to address wrapping issues. To do this provide ``project=True``, which will project the data before it is rasterized (this also works for other types and even when not using these operations). Another reason why this is important when rasterizing the data is that if the the CRS of the data does not match the displayed projection, all the data will be projected every time you zoom or pan, which can be very slow. Deciding whether to ``project`` is therefore a tradeoff between projecting the raw data ahead of time or accepting the overhead on dynamic zoom and pan actions."
"The first is using the ``rasterize`` or ``datashade`` options to regrid the data before rendering it, i.e., rendering the data on the backend and then sending a more efficient image-based representation to the browser. One thing to note when using these operations is that it may be necessary to project the data **before** rasterizing it, e.g. to address wrapping issues. To do this provide ``project=True``, which will project the data before it is rasterized (this also works for other types and even when not using these operations). Another reason why this is important when rasterizing the data is that if the CRS of the data does not match the displayed projection, all the data will be projected every time you zoom or pan, which can be very slow. Deciding whether to ``project`` is therefore a tradeoff between projecting the raw data ahead of time or accepting the overhead on dynamic zoom and pan actions."
]
},
{
Expand Down
8 changes: 4 additions & 4 deletions examples/user_guide/Gridded_Data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,11 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Datashading\n",
"## Rasterizing\n",
"\n",
"If you are plotting a large amount of data at once, you can consider using the hvPlot interface to [Datashader](http://datashader.org), which can be enabled simply by setting `datashade=True`.\n",
"If you are plotting a large amount of data at once, you can consider using the hvPlot interface to [Datashader](http://datashader.org), which can be enabled simply by setting `rasterize=True`.\n",
"\n",
"Note that be declaring that the data should not be grouped by another coordinate variable, by setting `groupby=[]`, we can plot all the datapoints, showing us the spread of air temperatures in the dataset:"
"Note that by declaring that the data should not be grouped by another coordinate variable, i.e. by setting `groupby=[]`, we can plot all the datapoints, showing us the spread of air temperatures in the dataset:"
]
},
{
Expand All @@ -274,7 +274,7 @@
"metadata": {},
"outputs": [],
"source": [
"air.hvplot.scatter('time', groupby=[], datashade=True) *\\\n",
"air.hvplot.scatter('time', groupby=[], rasterize=True) *\\\n",
"air.mean(['lat', 'lon']).hvplot.line('time', color='indianred')"
]
},
Expand Down
26 changes: 6 additions & 20 deletions examples/user_guide/Pandas_API.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -537,9 +537,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
},
"metadata": {},
"outputs": [],
"source": [
"plot_1 = df.plot.scatter(x='a', y='b', color='DarkBlue', label='Group 1')\n",
Expand Down Expand Up @@ -1013,9 +1011,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
},
"metadata": {},
"outputs": [],
"source": [
"(mean_std.plot.bar(y='mean', alpha=0.7) * \\\n",
Expand Down Expand Up @@ -1058,27 +1054,19 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
},
"metadata": {},
"outputs": [],
"source": [
"# Doesn't currently work as expected. Work-around:\n",
"\n",
"from holoviews.plotting.util import process_cmap\n",
"cmap = process_cmap('cubehelix', ncolors=10, categorical=True)\n",
"# cmap = 'cubehelix'\n",
"\n",
"df = pd.DataFrame(np.random.randn(1000, 10), index=ts.index)\n",
"df = df.cumsum()\n",
"df.plot(colormap=cmap)"
"df.plot(colormap='cubehelix')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Colormaps can also be used other plot types, like bar charts:"
"Colormaps can also be used with other plot types, like bar charts:"
]
},
{
Expand All @@ -1102,9 +1090,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
},
"metadata": {},
"outputs": [],
"source": [
"from bokeh.sampledata import iris\n",
Expand Down
15 changes: 9 additions & 6 deletions hvplot/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,17 @@ class HoloViewsConverter(object):
(warning: for large groupby operations embedded data can become
very large if dynamic=False)
datashade (default=False):
Whether to apply rasterization and shading using datashader
library returning an RGB object
Whether to apply rasterization and shading (colormapping) using
the Datashader library, returning an RGB object instead of
individual points
dynspread (default=False):
Allows plots generated with datashade=True or rasterize=True
to increase the point size to make sparse regions more visible
For plots generated with datashade=True or rasterize=True,
automatically increase the point size when the data is sparse
so that individual points become more visible
rasterize (default=False):
Whether to apply rasterization using the datashader library
returning an aggregated Image
Whether to apply rasterization using the Datashader library,
returning an aggregated Image (to be colormapped by the
plotting backend) instead of individual points
x_sampling/y_sampling (default=None):
Specifies the smallest allowed sampling interval along the x/y axis.
Expand Down
4 changes: 2 additions & 2 deletions hvplot/tests/testoperations.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def setUp(self):
except:
raise SkipTest('Datashader not available')
if sys.maxsize < 2**32:
raise SkipTest('Datashader does not work on 32-bit systems')
raise SkipTest('Datashader does not support 32-bit systems')
import hvplot.pandas # noqa
self.df = pd.DataFrame([[1, 2, 'A', 0.1], [3, 4, 'B', 0.2], [5, 6, 'C', 0.3]],
columns=['x', 'y', 'category', 'number'])
Expand Down Expand Up @@ -138,7 +138,7 @@ def setUp(self):
except:
raise SkipTest('xarray or datashader not available')
if sys.maxsize < 2**32:
raise SkipTest('Datashader does not work on 32-bit systems')
raise SkipTest('Datashader does not support 32-bit systems')
import hvplot.xarray # noqa
data = np.arange(0, 60).reshape(6, 10)
x = np.arange(10)
Expand Down

0 comments on commit 9c0886e

Please sign in to comment.