Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement cnorm option #4567

Merged
merged 98 commits into from
Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
486198f
Implement cnorm option
philippjfr Aug 25, 2020
ef999c9
Add minimum to count aggregations
philippjfr Aug 25, 2020
40f8899
Applied transparent clipping colors to Image min and max
jlstevens Sep 11, 2020
61ffe6a
Updated test_aggregate_curve unit test
jlstevens Sep 11, 2020
3d3c771
Fixed typo
jlstevens Sep 11, 2020
374ffcf
Updated more unit tests
jlstevens Sep 11, 2020
e829935
Updated redimming range on appropriate vdim
jlstevens Sep 11, 2020
baa2362
Fixed typos
jlstevens Sep 11, 2020
bd534fe
First cut at new nodata option for Rasters and QuadMeshes
jlstevens Sep 28, 2020
52d6edf
Added nodata support for Matplotlib rasters and quadmeshes
jlstevens Sep 28, 2020
d327a2b
Added nodata support for Plotly rasters and quadmeshes
jlstevens Sep 28, 2020
cbfc411
Update nodata docstring
jlstevens Sep 28, 2020
c4684fd
Updated nodata parameter definition throughout
jlstevens Sep 28, 2020
c985722
Raising a ValueError when using nodata with float data
jlstevens Sep 28, 2020
04d9c8c
Ignoring nodata option for float type data
jlstevens Sep 28, 2020
ba23bc8
Removed count range declaration to examine tests
jlstevens Sep 28, 2020
2e7bdf5
Reverted dimension range changes in unit tests
jlstevens Sep 29, 2020
15566f6
Removed unnecessary clipping_colors setting from options.Image
jlstevens Sep 29, 2020
6d3ab40
Formatting fixes in testdatashader.py
jlstevens Sep 29, 2020
ed16d1e
Removed unnecessary newline
jlstevens Sep 29, 2020
3570fb1
Applied docstring suggestions
jlstevens Sep 29, 2020
d435197
Updated docstring with suggestion
jlstevens Sep 29, 2020
aaa785a
Factored out an apply_nodata utility
jlstevens Sep 30, 2020
e555346
Updated docstring to make it clear than transparent NaNs is a default
jlstevens Sep 30, 2020
acd00bd
Renamed 'eqhist' to 'eq_hist' in cnorm parameter
jlstevens Sep 30, 2020
feb98b6
Added nodata unit tests for Image and Quadmesh across all backends
jlstevens Nov 19, 2020
388cdf2
Added unit tests for the cnorm plot option
jlstevens Nov 19, 2020
00dae03
Added description of cnorm option to style mapping user guide
jlstevens Nov 20, 2020
9d64c77
Raising more helpful import error when EqHistColorMapper unavailable
jlstevens Nov 20, 2020
84cb408
Fixed apply_nodata utility to handle unsigned ints
jlstevens Nov 20, 2020
5dd266d
Updated the Large Data user guide with cnorm and nodata example
jlstevens Nov 20, 2020
be74992
Added unit tests for nodata when data is unsigned int
jlstevens Nov 20, 2020
969aa17
Apply nodata in Compositor
philippjfr Nov 20, 2020
f0b64c9
Fix for xarray
philippjfr Nov 20, 2020
cdc7b8c
Fix for Raster
philippjfr Nov 20, 2020
03c6977
Switched new rasterize example in large data to viridis
jlstevens Nov 20, 2020
bca3321
Fixed error message formatting
jbednar Nov 20, 2020
c5e4de3
Updated user guide
jbednar Nov 20, 2020
8e5f7ce
Fix inverted mask
philippjfr Nov 23, 2020
96dc926
Fixed unpacking on single element compositor
philippjfr Nov 23, 2020
28623b9
Update tests
philippjfr Nov 23, 2020
715a399
Further test fixes
philippjfr Nov 23, 2020
b7b5cc5
Further test fixes
philippjfr Nov 23, 2020
caaee00
Implement Dimension.nodata support
philippjfr Nov 25, 2020
063a72c
Fixed flake
philippjfr Nov 25, 2020
9c3b61f
Cleaned up wording
jbednar Nov 26, 2020
27a12e8
Set default colormap to match shade. Use separate xy/uv and count dim…
jbednar Nov 26, 2020
514d42e
Added vdim_suffix parameter to AggregationOperation
jlstevens Nov 30, 2020
e762da7
Unify handling of trimesh rasterize parameters
philippjfr Nov 30, 2020
3b37725
Keep Dimension.label unchanged
philippjfr Nov 30, 2020
9680d28
Switche default cmap for Charts
philippjfr Nov 30, 2020
646753e
Enhance Store.transfer_options
philippjfr Nov 30, 2020
77fe29c
Transfer cmap on rasterize
philippjfr Nov 30, 2020
1f25411
Updated datashader docs
philippjfr Nov 30, 2020
5139d5e
Fix categorical label
philippjfr Nov 30, 2020
e474ff0
Fixed boolean handling
philippjfr Nov 30, 2020
e4dd3e4
Fixed missing import
jlstevens Nov 30, 2020
00274bd
Fix transfer_opts
philippjfr Nov 30, 2020
3e85192
Fix version check
philippjfr Nov 30, 2020
6d489e5
Skipping Polygon rasterization if spatialpandas unavailable
jlstevens Nov 30, 2020
44d8591
Fixed clim_percentile and eq_hist docs
jbednar Dec 1, 2020
27af0b3
Updated 14-Large_Data.ipynb to use rasterize throughout
jbednar Dec 1, 2020
104e349
Fixed 15-Large_Data regressions
jbednar Dec 1, 2020
47c8a38
Implement nodata range
philippjfr Dec 1, 2020
1117d56
Add Rectangles example
philippjfr Dec 1, 2020
9b6a9c5
Polygons and Rectangles coloring
philippjfr Dec 1, 2020
dc7296d
Switch to vdim_prefix
philippjfr Dec 1, 2020
e88aa56
Fixed lingering vdim_suffix references
jlstevens Dec 1, 2020
60c2e7b
Improved error message in spreading operation for wrong input types
jlstevens Dec 1, 2020
ff852df
Implement per_element for dynamic Operations
philippjfr Dec 1, 2020
d8c49c5
Support match_spec on numpy booleans
philippjfr Dec 1, 2020
4570f7a
Removed unnecessary uses of dynamic=False
jlstevens Dec 1, 2020
0a80c05
Update vdim_prefix in tests
philippjfr Dec 1, 2020
c6cc3eb
Update default colormap for Path and geometry types
philippjfr Dec 1, 2020
de60432
Update default cmap for Spikes
philippjfr Dec 1, 2020
6693d4b
Enable BinnedTicker
philippjfr Dec 1, 2020
311771c
Add redim.nodata
philippjfr Dec 1, 2020
cf9205d
Fix cmap handling on matplotlib collections
philippjfr Dec 1, 2020
63da62e
Switch to numerical colormapping on Polygons
philippjfr Dec 1, 2020
00ac897
Various bug fixes
philippjfr Dec 1, 2020
6b8e2c2
Handle updates to vmin/vmax/clim
philippjfr Dec 1, 2020
3c27e92
Deprecated normalization parameter in favor of cnorm
jlstevens Dec 1, 2020
87f1b7e
Removed dflt_chart_cmap and setting dflt_cmap via hv.config.default_cmap
jlstevens Dec 1, 2020
127e0bf
Fixed triggering mechanism and updates to Range streams
philippjfr Dec 1, 2020
95fe176
Put the normalization parameter warning behind future_deprecations
jlstevens Dec 1, 2020
c3a55fc
Setting dflt_cmap where dflt_chart_cmap used to be set
jlstevens Dec 1, 2020
41d6610
Fixed flake
jlstevens Dec 1, 2020
cb9a923
Registering kbc_r in matplotlib and setting it as the default
jlstevens Dec 1, 2020
4a94fd2
Set default cmap for bokeh and matplotlib TriMesh and plotly TriSurface
jlstevens Dec 1, 2020
19ce288
Removed 'cmap' from _transfer_options
jlstevens Dec 1, 2020
b77d29f
Added hv.config.default_gridded_cmap option
jlstevens Dec 1, 2020
c72f83b
Simplified registration of kbc_r colormap
jlstevens Dec 1, 2020
85f3e5a
Warn for duplicated cnorm/normalization args
jbednar Dec 1, 2020
0245401
Fix copy/paste error
philippjfr Dec 1, 2020
0585437
Fixed typo
jbednar Dec 1, 2020
d07f151
Fixed i.e./e.g.
jbednar Dec 1, 2020
563a072
Updated clash warning when both cnorm and normalization supplied
jlstevens Dec 1, 2020
b9680e3
Added hv.config.default_heatmap_cmap option
jlstevens Dec 1, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 60 additions & 6 deletions examples/user_guide/04-Style_Mapping.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@
"source": [
"### Explicit color mapping\n",
"\n",
"Some elements work through implicit colormapping the prime example being the ``Image`` type, however other elements can be colormapped using style mapping instead, by setting the color to an existing dimension."
"Some elements work through implicit colormapping, the prime example being the ``Image`` type. However, other elements can be colormapped using style mapping instead, by setting the color to an existing dimension."
]
},
{
Expand Down Expand Up @@ -521,12 +521,66 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"By default (left plot above), the min and max values in the array map to the first color (white) and last color (dark blue) in the colormap, and NaNs are ``'transparent'`` (an RGBA tuple of (0, 0, 0, 0)), revealing the underlying plot background. When the specified `clipping_colors` are supplied (middle plot above), NaN values are now colored gray, but the plot is otherwise the same because the autoranging still ensures that no value is mapped outside the available color range. Finally, when the `z` range is reduced (right plot above), the color range is mapped from a different range of numerical `z` values, and some values now fall outside the range and are thus clipped to red or green as specified.\n",
" \n",
"#### Other options\n",
"By default (left plot above), the min and max values in the array map to the first color (white) and last color (dark blue) in the colormap, and NaNs are ``'transparent'`` (an RGBA tuple of (0, 0, 0, 0)), revealing the underlying plot background. When the specified `clipping_colors` are supplied (middle plot above), NaN values are now colored gray, but the plot is otherwise the same because the autoranging still ensures that no value is mapped outside the available color range. Finally, when the `z` range is reduced (right plot above), the color range is mapped from a different range of numerical `z` values, and some values now fall outside the range and are thus clipped to red or green as specified.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Normalization modes\n",
"\n",
"When using a colormap, there are three available color normalization or `cnorm` options to determine how numerical values are mapped to the range of colors in the colorbar:\n",
"\n",
"* `linear`: Simple linear mapping (used by default)\n",
"* `log`: Logarithmic mapping\n",
"* `eq_hist`: Histogram-equalized mapping\n",
"\n",
"The following cell defines an `Image` containing random samples drawn from a normal distribution (mean of 3) with a square of constant value 100 in the middle, shown with the three `cnorm` modes:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"np.random.seed(42)\n",
"data = np.random.normal(loc=3, scale=0.3, size=(100,100))\n",
"print(\"Mean value of random samples is {mean:.3f}, \".format(mean=np.mean(data))\n",
" + \"which is much lower\\nthan the black square in the center (value 100).\")\n",
"data[45:55,45:55] = 100\n",
"\n",
"opts=dict(colorbar=True, xaxis='bare', yaxis='bare', height=160, width=200)\n",
"pattern = hv.Image(data)\n",
"\n",
"( pattern.options(cnorm='linear', title='linear', **opts) \n",
" + pattern.options(cnorm='log', title='log', **opts)\n",
" + pattern.options(cnorm='eq_hist', title='eq_hist', **opts))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The `'linear'` mode is very easy to interpret numerically, with colors mapped to numerical values linearly as indicated. However, as you can see in this case, high-value outliers like the square here can make it difficult to see any structure in the remaining values. The Gaussian noise values all map to the first few colors at the bottom of the colormap, resulting in a background that is almost uniformly yellow even though we know the data includes a variety of different values in the background area.\n",
"\n",
"In the `'log'` mode, the random values are a little easier to see but these samples still use a small portion of the colormap. Logarithmic colormaps are most useful when you know that you are plotting data with an approximately logarithmic distribution.\n",
"\n",
"In the `'eq_hist'` mode, colors are nonlinearly mapped according to the actual distribution of values in the plot, such that each color in the colormap represents an approximately equal number of values in the plot (here with few or no colors reserved for the nearly empty range between 10 and 100). In this mode both the outliers and the overall low-amplitude noise can be seen clearly, but the non-linear distortion can make the colors more difficult to interpret as numerical values.\n",
"\n",
"When working with unknown data distributions, it is often a good idea to try all three of these modes, using `eq_hist` to be sure that you are seeing all of the patterns in the data, then either `log` or `linear` (depending on which one is a better match to your distribution) with the values clipped to the range of values you want to show."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Other colormapping options\n",
"\n",
"* ``clim_percentile``: Percentile value to compute colorscale robust to outliers. If `True` uses 2nd and 98th percentile, otherwise uses the specified percentile value. \n",
"* ``cnorm``: Color normalization to be applied during colormapping. Allows switching between 'linear', 'log' and 'eqhist'.\n",
"* ``clim_percentile``: Percentile value to compute colorscale robust to outliers. If `True`, uses 2nd and 98th percentile; otherwise uses the specified percentile value. \n",
"* ``cnorm``: Color normalization to be applied during colormapping. Allows switching between 'linear', 'log', and 'eq_hist'.\n",
"* ``logz``: Enable logarithmic color scale (same as `cnorm='log'`; to be deprecated at some point)\n",
"* ``symmetric``: Ensures that the color scale is centered on zero (e.g. ``symmetric=True``)"
]
},
Expand Down
Loading