ahuang11 commited on
Commit
067c884
1 Parent(s): 2266f02

Upload 5 files

Browse files
hvplot_docs/.DS_Store ADDED
Binary file (6.15 kB). View file
 
hvplot_docs/02-Composing_Elements.md ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Composing Objects
2
+
3
+
4
+ ```python
5
+ import numpy as np
6
+ import holoviews as hv
7
+ hv.extension('bokeh')
8
+ ```
9
+
10
+ Instantly viewable HoloViews objects include elements (discussed already) and containers (collections of elements or other containers). Here we'll introduce two types of containers for collecting viewable objects, each typically created from the existing objects using a convenient operator syntax:
11
+
12
+ 1. ** [``Layout``](../reference/containers/bokeh/Layout.ipynb) (``+``):** A collection of any HoloViews objects to be displayed side by side.
13
+ 2. **[``Overlay``](../reference/containers/bokeh/Overlay.ipynb) (``*``):** A collection of HoloViews objects to be displayed overlaid on one another with the same axes.
14
+
15
+ The Layout and Overlay containers allow you to mix types in any combination, and have an ordering but no numerical or categorical key dimension with which to index the objects. In contrast, the [Dimensioned containers](./05-Dimensioned_Containers.ipynb) discussed later, such as [``HoloMap``](../reference/containers/bokeh/HoloMap.ipynb) , [``GridSpace``](../reference/containers/bokeh/GridSpace.ipynb), [``NdOverlay``](../reference/containers/bokeh/NdOverlay.ipynb), and [``NdLayout``](../reference/containers/bokeh/NdLayout.ipynb), do not allow mixed types, and each item has an associated numerical or categorical index (key).
16
+
17
+ Because you can compose a mix of any HoloViews elements into layouts and overlays, these types of container are very common, which is why they have dedicated composition operators. This user guide describes how you can build and organize your data using these two types of composition.
18
+
19
+ To show how layouts and overlays work with heterogeneous types, we will use these two elements throughout this notebook:
20
+
21
+
22
+ ```python
23
+ xs = [0.1* i for i in range(100)]
24
+ curve = hv.Curve((xs, [np.sin(x) for x in xs]))
25
+ scatter = hv.Scatter((xs[::5], np.linspace(0,1,20)))
26
+ ```
27
+
28
+ ## 1. ``Layout``
29
+
30
+ A ``Layout`` can contain any HoloViews object except an ``NdLayout``. (See [Building Composite Objects](06-Building_Composite_Objects.ipynb) for the full details about the ways containers can be composed.)
31
+
32
+ You can build a ``Layout`` from two or more HoloViews objects of any type by using the ``+`` operator:
33
+
34
+
35
+ ```python
36
+ curve + scatter
37
+ ```
38
+
39
+ In this example, we have a ``Layout`` composed of a ``Curve`` element and a ``Scatter`` element, and they happen to share the same ``x`` and ``y`` dimensions.
40
+
41
+ ### Building a ``Layout`` from a list
42
+
43
+ If the ``+`` syntax is not convenient, you can also build a ``Layout`` using its constructor directly, which is useful if you want to create a ``Layout`` of an arbitrary length:
44
+
45
+
46
+ ```python
47
+ curve_list = [hv.Curve((xs, [np.sin(f*x) for x in xs])) for f in [0.5, 0.75]]
48
+ scatter_list = [hv.Scatter((xs[::5], f*np.linspace(0,1,20))) for f in [-0.5, 0.5]]
49
+
50
+ layout = hv.Layout(curve_list + scatter_list).cols(2)
51
+ layout
52
+ ```
53
+
54
+ Note the use of the ``.cols`` method to specify the number of columns, wrapping to the next row in scanline order (left to right, then top to bottom).
55
+
56
+ ### A ``Layout`` has two-level attribute access
57
+
58
+ ``Layout`` and ``Overlay`` are tree-based data structures that can hold arbitrarily heterogeneous collections of HoloViews objects, and are quite different from the dictionary-like dimensioned containers (which will be described in later guides).
59
+
60
+ As mentioned previously in [Annotating Data](01-Annotating_Data.ipynb), HoloViews objects have string ``group`` and ``label`` parameters, which can be used to select objects in the ``Layout`` using two-level attribute access. First let us see how to index the above example, where the ``group`` and ``label`` parameters were left unspecified on creation:
61
+
62
+
63
+ ```python
64
+ print(layout)
65
+ ```
66
+
67
+ As you can see, the ``layout`` object consists of four different elements, each mapping from ``x`` to ``y``. You can use the "dot" syntax shown in the repr to select individual elements from the layout:
68
+
69
+
70
+ ```python
71
+ layout2 = layout.Curve.I + layout.Scatter.II
72
+ layout2
73
+ ```
74
+
75
+ Here we create a second layout by indexing two elements from our earlier ``layout`` object and using ``+`` between them. We see that the first level of indexing is the ``group`` string (which defaults to the element class name) followed by the label, which wasn't set and is therefore mapped to an automatically generated Roman numeral (I,II,III,IV, etc.).
76
+
77
+ As group and label were again not specified, our new ``Layout`` will also use ``Curve.I`` for the curve, but as there is only one scatter element, it will have ``Scatter.I`` to index the scatter:
78
+
79
+
80
+ ```python
81
+ layout2.Scatter.I
82
+ ```
83
+
84
+ ### Using ``group`` and ``label`` with ``Layout``
85
+
86
+ Now let's return to the first simple layout example, this time setting a group and label as introduced in the [Annotating Data](./01-Annotating_Data.ipynb) guide:
87
+
88
+
89
+ ```python
90
+ xs = [0.1* i for i in range(100)]
91
+
92
+ low_freq = hv.Curve((xs, [np.sin(x) for x in xs]), group='Sinusoid', label='Low Frequency')
93
+ linpoints = hv.Scatter((xs[::5], np.linspace(0,1,20)), group='Linear Points', label='Demo')
94
+
95
+ labelled = low_freq + linpoints
96
+ labelled
97
+ ```
98
+
99
+ As you can see, the group and label are used for titling the plots. They also determine how the objects are accessed:
100
+
101
+
102
+ ```python
103
+ labelled.Linear_Points.Demo + labelled.Sinusoid.Low_Frequency
104
+ ```
105
+
106
+ You are encouraged to use the group and label names as appropriate for organizing your own data. They should let you easily refer to groups of data that are meaningful to your domain, e.g. for [Applying Customizations](./03-Applying_Customizations.ipynb).
107
+
108
+ ## 2. ``Overlay``
109
+
110
+ An ``Overlay`` can contain any HoloViews elements, but the only container type it can contain is ``NdOverlay``. [Building Composite Objects](06-Building_Composite_Objects.ipynb) provides the full details on how containers can be composed.
111
+
112
+ Other than being composed with ``*`` and displaying elements together in the same space, ``Overlay`` shares many of the same concepts as layout. The rest of this section will show the overlay equivalents of the manipulations shown above for layout.
113
+
114
+ First, composition with ``*`` instead of ``+`` results in a single overlaid plot, rather than side-by-side plots:
115
+
116
+
117
+ ```python
118
+ curve * scatter
119
+ ```
120
+
121
+ ### Building ``Overlay`` from a list
122
+
123
+ An ``Overlay`` can be built explicitly from a list, just like a ``Layout``:
124
+
125
+
126
+ ```python
127
+ curve_list = [hv.Curve((xs, [np.sin(f*x) for x in xs])) for f in [0.5, 0.75]]
128
+ scatter_list = [hv.Scatter((xs[::5], f*np.linspace(0,1,20))) for f in [-0.5, 0.5]]
129
+ overlay = hv.Overlay(curve_list + scatter_list)
130
+ overlay
131
+ ```
132
+
133
+ As you can see, a special feature of ``Overlay`` compared to ``Layout`` is that overlays use *color cycles* to help keep the overlaid plots distinguishable, which you can learn about in [Applying Customization](./03-Applying_Customization.ipynb).
134
+
135
+ ### ``Overlay`` also has two-level attribute access
136
+
137
+ Like ``Layout``, ``Overlay`` is fundamentally a tree structure holding arbitrarily heterogeneous HoloViews objects, unlike the dimensioned containers. ``Overlay`` objects also make use of the ``group`` and ``label`` parameters, introduced in [Annotating Data](01-Annotating_Data.ipynb), for two-level attribute access.
138
+
139
+ Once again, let us see how to index the above example where the ``group`` and ``label`` parameters were left unspecified:
140
+
141
+
142
+ ```python
143
+ print(overlay)
144
+ ```
145
+
146
+
147
+ ```python
148
+ overlay.Curve.I * overlay.Scatter.II
149
+ ```
150
+
151
+ Here we create a second overlay by indexing two elements from our earlier ``overlay`` object and using ``*`` between them. We see that the first level is the ``group`` string (which defaults to the element class name) followed by the label, which wasn't set and is therefore mapped to a Roman numeral.
152
+
153
+ ### Using ``group`` and ``label`` with ``Overlay``
154
+
155
+ Now let's return to the first simple overlay example, this time setting ``group`` and ``label`` as introduced in the [Annotating Data](./01-Annotating_Data.ipynb) guide:
156
+
157
+
158
+ ```python
159
+ high_freq = hv.Curve((xs, [np.sin(2*x) for x in xs]), group='Sinusoid', label='High Frequency')
160
+ labelled = low_freq * high_freq * linpoints
161
+ labelled
162
+ ```
163
+
164
+ Once again, this example follows the corresponding ``Layout`` example, although this time we added a high-frequency curve to demonstrate how ``group`` and ``label`` are now used to generate the legend (as opposed to the title, as it was for ``Layout``).
165
+
166
+ The following example shows how ``group`` and ``label`` affect access:
167
+
168
+
169
+ ```python
170
+ labelled.Linear_Points.Demo * labelled.Sinusoid.High_Frequency * labelled.Sinusoid.Low_Frequency
171
+ ```
172
+
173
+ This new re-ordered ``Overlay`` switches the z-ordering as well as the legend color of the two sinusoidal curves. The colors and other plot options can be set for specific groups and labels as described in
174
+ [Applying Customizations](./03-Applying_Customizations.ipynb).
175
+
176
+
177
+ ## Layouts of overlays
178
+
179
+ Of course, layouts work with both elements and overlays:
180
+
181
+
182
+ ```python
183
+ overlay + labelled + labelled.Sinusoid.Low_Frequency
184
+ ```
185
+
186
+ ## Tab completion
187
+
188
+ Both ``Layout`` and ``Overlay`` are designed to be easy to explore and inspect with tab completion. Try running:
189
+
190
+ ```python
191
+ overlay.[tab]
192
+ ```
193
+
194
+ or
195
+
196
+ ```python
197
+ layout.[tab]
198
+ ```
199
+
200
+
201
+ In a code cell and you should see the first levels of indexing (``Curve`` and ``Scatter``) conveniently listed at the top. If this is not the case, you may need to enable improved tab-completion as described in [Configuring HoloViews](./Installing_and_Configuring.ipynb).
202
+
203
+ Having seen how to compose viewable objects, the next section shows how to [apply customizations](./03-Applying_Customizations.ipynb).
hvplot_docs/03-Applying_Customizations.md ADDED
@@ -0,0 +1,470 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Applying Customizations
2
+
3
+
4
+ ```python
5
+ import pandas as pd
6
+ import numpy as np
7
+ import holoviews as hv
8
+ from holoviews import opts
9
+ hv.extension('bokeh', 'matplotlib')
10
+ ```
11
+
12
+ As introduced in the [Customization](../getting_started/2-Customization.ipynb) section of the 'Getting Started' guide, HoloViews maintains a strict separation between your content (your data and declarations about your data) and its presentation (the details of how this data is represented visually). This separation is achieved by maintaining sets of keyword values ("options") that specify how elements are to appear, stored outside of the element itself. Option keywords can be specified for individual element instances, for all elements of a particular type, or for arbitrary user-defined sets of elements that you give a certain ``group`` and ``label`` (see [Annotating Data](../user_guide/01-Annotating_Data.ipynb)).
13
+
14
+ The options system controls how individual plots appear, but other important settings are made more globally using the "output" system, which controls HoloViews plotting and rendering code (see the [Plots and Renderers](Plots_and_Renderers.ipynb) user guide). In this guide we will show how to customize the visual styling with the options and output systems, focusing on the mechanisms rather than the specific choices available (which are covered in other guides such as [Style Mapping](04-Style_Mapping.ipynb)).
15
+
16
+ ## Core concepts
17
+
18
+ This section offers an overview of some core concepts for customizing visual representation, focusing on how HoloViews keeps content and presentation separate. To start, we will revisit the simple introductory example in the [Customization](../getting_started/2-Customization.ipynb) getting-started guide (which might be helpful to review first).
19
+
20
+
21
+ ```python
22
+ spike_train = pd.read_csv('../assets/spike_train.csv.gz')
23
+ curve = hv.Curve(spike_train, 'milliseconds', 'Hertz')
24
+ spikes = hv.Spikes(spike_train, 'milliseconds', [])
25
+ ```
26
+
27
+ And now we display the ``curve`` and a ``spikes`` elements together in a layout as we did in the getting-started guide:
28
+
29
+
30
+ ```python
31
+ curve = hv.Curve( spike_train, 'milliseconds', 'Hertz')
32
+ spikes = hv.Spikes(spike_train, 'milliseconds', [])
33
+ layout = curve + spikes
34
+
35
+ layout.opts(
36
+ opts.Curve( height=200, width=900, xaxis=None, line_width=1.50, color='red', tools=['hover']),
37
+ opts.Spikes(height=150, width=900, yaxis=None, line_width=0.25, color='grey')).cols(1)
38
+ ```
39
+
40
+ This example illustrates a number of key concepts, as described below.
41
+
42
+ ### Content versus presentation
43
+
44
+ In the getting-started guide [Introduction](../getting_started/1-Introduction.ipynb), we saw that we can print the string representation of HoloViews objects such as `layout`:
45
+
46
+
47
+ ```python
48
+ print(layout)
49
+ ```
50
+
51
+ In the [Customization](../getting_started/2-Customization.ipynb) getting-started guide, the `.opts.info()` method was introduced that lets you see the options *associated* with (though not stored on) the objects:
52
+
53
+
54
+ ```python
55
+ layout.opts.info()
56
+ ```
57
+
58
+ If you inspect all the state of the `Layout`, `Curve`, or `Spikes` objects you will not find any of these keywords, because they are stored in an entirely separate data structure. HoloViews assigns a unique ID per HoloViews object that lets arbitrarily specific customization be associated with that object if needed, while also making it simple to define options that apply to entire classes of objects by type (or group and label if defined). The HoloViews element is thus *always* a thin wrapper around your data, without any visual styling information or plotting state, even though it *seems* like the object includes the styling information. This separation between content and presentation is by design, so that you can work with your data and with its presentation entirely independently.
59
+
60
+ If you wish to clear the options that have been associated with an object `obj`, you can call `obj.opts.clear()`.
61
+
62
+ ## Option builders
63
+
64
+ The [Customization](../getting_started/2-Customization.ipynb) getting-started guide also introduces the notion of *option builders*. One of the option builders in the visualization shown above is:
65
+
66
+
67
+ ```python
68
+ opts.Curve( height=200, width=900, xaxis=None, line_width=1.50, color='red', tools=['hover'])
69
+ ```
70
+
71
+ An *option builder* takes a collection of keywords and returns an `Options` object that stores these keywords together. Why should you use option builders and how are they different from a vanilla dictionary?
72
+
73
+ 1. The option builder specifies which type of HoloViews object the options are for, which is important because each type accepts different options.
74
+ 2. Knowing the type, the options builder does *validation* against that type for the currently loaded plotting extensions. Try introducing a typo into one of the keywords above; you should get a helpful error message. Separately, try renaming `line_width` to `linewidth`, and you'll get a different message because the latter is a valid matplotlib keyword.
75
+ 3. The option builder allows *tab-completion* in the notebook. This is useful for discovering available keywords for that type of object, which helps prevent mistakes and makes it quicker to specify a set of keywords.
76
+
77
+ In the cell above, the specified options are applicable to `Curve` elements, and different validation and tab completion will be available for other types.
78
+
79
+ The returned `Options` object is different from a dictionary in the following ways:
80
+
81
+ 1. An optional *spec* is recorded, where this specification is normally just the element name. Above this is simply 'Curve'. Later, in section [Using `group` and `label`](#Using-group-and-label), we will see how this can also specify the `group` and `label`.
82
+ 2. The keywords are alphanumerically sorted, making it easier to compare `Options` objects.
83
+
84
+ ## Inlining options
85
+
86
+ When customizing a single element, the use of an option builder is not mandatory. If you have a small number of keywords that are common (e.g `color`, `cmap`, `title`, `width`, `height`) it can be clearer to inline them into the `.opts` method call if tab-completion and validation isn't required:
87
+
88
+
89
+ ```python
90
+ np.random.seed(42)
91
+ array = np.random.random((10,10))
92
+ im1 = hv.Image(array).opts(opts.Image(cmap='Reds')) # Using an option builder
93
+ im2 = hv.Image(array).opts(cmap='Blues') # Without an option builder
94
+ im1 + im2
95
+ ```
96
+
97
+ You cannot inline keywords for composite objects such as `Layout` or `Overlay` objects. For instance, the `layout` object is:
98
+
99
+
100
+ ```python
101
+ print(layout)
102
+ ```
103
+
104
+ To customize this layout, you need to use an option builder to associate your keywords with either the `Curve` or the `Spikes` object, or else you would have had to apply the options to the individual elements before you built the composite object. To illustrate setting by type, note that in the first example, both the `Curve` and the `Spikes` have different `height` values provided.
105
+
106
+ You can also target options by the `group` and `label` as described in section on [using `group` and `label`](#Using-group-and-label).
107
+
108
+ ## Session-specific options
109
+
110
+ One other common need is to set some options for a Python session, whether using Jupyter notebook or not. For this you can set the default options that will apply to all objects created subsequently:
111
+
112
+
113
+ ```python
114
+ opts.defaults(
115
+ opts.HeatMap(cmap='Summer', colorbar=True, toolbar='above'))
116
+ ```
117
+
118
+ The `opts.defaults` method has now set the style used for all `HeatMap` elements used in this session:
119
+
120
+
121
+ ```python
122
+ data = [(chr(65+i), chr(97+j), i*j) for i in range(5) for j in range(5) if i!=j]
123
+ heatmap = hv.HeatMap(data).sort()
124
+ heatmap
125
+ ```
126
+
127
+ ## Discovering options
128
+
129
+ Using tab completion in the option builders is one convenient and easy way of discovering the available options for an element. Another approach is to use `hv.help`.
130
+
131
+ For instance, if you run `hv.help(hv.Curve)` you will see a list of the 'style' and 'plot' options applicable to `Curve`. The distinction between these two types of options can often be ignored for most purposes, but the interested reader is encouraged to read more about them in more detail [below](#Split-into-style,-plot-and-norm-options).
132
+
133
+ For the purposes of discovering the available options, the keywords listed under the 'Style Options' section of the help output is worth noting. These keywords are specific to the active plotting extension and are part of the API for that plotting library. For instance, running `hv.help(hv.Curve)` in the cell below would give you the keywords in the Bokeh documentation that you can reference for customizing the appearance of `Curve` objects.
134
+
135
+
136
+
137
+ ## Maximizing readability
138
+
139
+ There are many ways to specify options in your code using the above tools, but for creating readable, maintainable code, we recommend making the separation of content and presentation explicit. Someone reading your code can then understand your visualizations in two steps 1) what your data *is* in terms of the applicable elements and containers 2) how this data is to be presented visually.
140
+
141
+ The following guide details the approach we have used through out the examples and guides on holoviews.org. We have found that following these rules makes code involving holoviews easier to read and more consistent.
142
+
143
+ The core principle is as follows: ***avoid mixing declarations of data, elements and containers with details of their visual appearance***.
144
+
145
+ ### Two contrasting examples
146
+
147
+ One of the best ways to do this is to declare all your elements, compose them and then apply all the necessary styling with the `.opts` method before the visualization is rendered to disk or to the screen. For instance, the example from the getting-started guide could have been written sub-optimally as follows:
148
+
149
+ ***Sub-optimal***
150
+ ```python
151
+ curve = hv.Curve( spike_train, 'milliseconds', 'Hertz').opts(
152
+ height=200, width=900, xaxis=None, line_width=1.50, color='red', tools=['hover'])
153
+ spikes = hv.Spikes(spike_train, 'milliseconds', vdims=[]).opts(
154
+ height=150, width=900, yaxis=None, line_width=0.25, color='grey')
155
+ (curve + spikes).cols(1)
156
+ ```
157
+
158
+ Code like that is very difficult to read because it mixes declarations of the data and its dimensions with details about how to present it. The recommended version declares the `Layout`, then separately applies all the options together where it's clear that they are just hints for the visualization:
159
+
160
+ ***Recommended***
161
+ ```python
162
+ curve = hv.Curve( spike_train, 'milliseconds', 'Hertz')
163
+ spikes = hv.Spikes(spike_train, 'milliseconds', [])
164
+ layout = curve + spikes
165
+
166
+ layout.opts(
167
+ opts.Curve( height=200, width=900, xaxis=None, line_width=1.50, color='red', tools=['hover']),
168
+ opts.Spikes(height=150, width=900, yaxis=None, line_width=0.25, color='grey')).cols(1)
169
+ ```
170
+
171
+
172
+ By grouping the options in this way and applying them at the end, you can see the definition of `layout` without being distracted by visual concerns declared later. Conversely, you can modify the visual appearance of `layout` easily without needing to know exactly how it was defined. The [coding style guide](#Coding-style-guide) section below offers additional advice for keeping things readable and consistent.
173
+
174
+ ### When to use multiple`.opts` calls
175
+
176
+ The above coding style applies in many case, but sometimes you have multiple elements of the same type that you need to distinguish visually. For instance, you may have a set of curves where using the `dim` or `Cycle` objects (described in the [Style Mapping](04-Style_Mapping.ipynb) user guide) is not appropriate and you want to customize the appearance of each curve individually. Alternatively, you may be generating elements in a list comprehension for use in `NdOverlay` and have a specific style to apply to each one.
177
+
178
+ In these situations, it is often appropriate to use the inline style of `.opts` locally. In these instances, it is often best to give the individually styled objects a suitable named handle as illustrated by the [legend example](../gallery/demos/bokeh/legend_example.ipynb) of the gallery.
179
+
180
+ ### General advice
181
+
182
+ As HoloViews is highly compositional by design, you can always build long expressions mixing the data and element declarations, the composition of these elements, and their customization. Even though such expressions can be terse they can also be difficult to read.
183
+
184
+ The simplest way to avoid long expressions is to keep some level of separation between these stages:
185
+
186
+ 1. declaration of the data
187
+ 2. declaration of the elements, including `.opts` to distinguish between elements of the same type if necessary
188
+ 3. composition with `+` and `*` into layouts and overlays, and
189
+ 4. customization of the composite object, either with a final call to the `.opts` method, or by declaring such settings as the default for your entire session as described [above](#Session-specific-options).
190
+
191
+ When stages are simple enough, it can be appropriate to combine them. For instance, if the declaration of the data is simple enough, you can fold in the declaration of the element. In general, any expression involving three or more of these stages will benefit from being broken up into several steps.
192
+
193
+ These general principles will help you write more readable code. Maximizing readability will always require some level of judgement, but you can maximize consistency by consulting the [coding style guide](#Coding-style-guide) section for more tips.
194
+
195
+ # Customizing display output
196
+
197
+
198
+ The options system controls most of the customizations you might want to do, but there are a few settings that are controlled at a more general level that cuts across all HoloViews object types: the active plotting extension (e.g. Bokeh or Matplotlib), the output display format (PNG, SVG, etc.), the output figure size, and other similar options. The `hv.output` utility allows you to modify these more global settings, either for all subsequent objects or for one particular object:
199
+
200
+ * `hv.output(**kwargs)`: Customize how the output appears for the rest of the notebook session.
201
+ * `hv.output(obj, **kwargs)`: Temporarily affect the display of an object `obj` using the keyword `**kwargs`.
202
+
203
+ The `hv.output` utility only has an effect in contexts where HoloViews objects can be automatically displayed, which currently is limited to the Jupyter Notebook (in either its classic or JupyterLab variants). In any other Python context, using `hv.output` has no effect, as there is no automatically displayed output; see the [hv.save() and hv.render()](Plots_and_Renderers.ipynb#Saving-and-rendering) utilities for explicitly creating output in those other contexts.
204
+
205
+ To start with `hv.output`, let us define a `Path` object:
206
+
207
+
208
+ ```python
209
+ lin = np.linspace(0, np.pi*2, 200)
210
+
211
+ def lissajous(t, a, b, delta):
212
+ return (np.sin(a * t + delta), np.sin(b * t), t)
213
+
214
+ path = hv.Path([lissajous(lin, 3, 5, np.pi/2)])
215
+ path.opts(opts.Path(color='purple', line_width=3, line_dash='dotted'))
216
+ ```
217
+
218
+ Now, to illustrate, let's use `hv.output` to switch our plotting extension to matplotlib:
219
+
220
+
221
+ ```python
222
+ hv.output(backend='matplotlib', fig='svg')
223
+ ```
224
+
225
+ We can now display our `path` object with some option customization:
226
+
227
+
228
+ ```python
229
+ path.opts(opts.Path(linewidth=2, color='red', linestyle='dotted'))
230
+ ```
231
+
232
+ Our plot is now rendered with Matplotlib, in SVG format (try right-clicking the image in the web browser and saving it to disk to confirm). Note that the `opts.Path` option builder now tab completes *Matplotlib* keywords because we activated the Matplotlib plotting extension beforehand. Specifically, `linewidth` and `linestyle` don't exist in Bokeh, where the corresponding options are called `line_width` and `line_dash` instead.
233
+
234
+ You can see the custom output options that are currently active using `hv.output.info()`:
235
+
236
+
237
+ ```python
238
+ hv.output.info()
239
+ ```
240
+
241
+ The info method will always show which backend is active as well as any other custom settings you have specified. These settings apply to the subsequent display of all objects unless you customize the output display settings for a single object.
242
+
243
+
244
+ To illustrate how settings are kept separate, let us switch back to Bokeh in this notebook session:
245
+
246
+
247
+ ```python
248
+ hv.output(backend='bokeh')
249
+ hv.output.info()
250
+ ```
251
+
252
+ With Bokeh active, we can now declare options on `path` that we want to apply only to matplotlib:
253
+
254
+
255
+ ```python
256
+ path = path.opts(
257
+ opts.Path(linewidth=3, color='blue', backend='matplotlib'))
258
+ path
259
+ ```
260
+
261
+ Now we can supply `path` to `hv.output` to customize how it is displayed, while activating matplotlib to generate that display. In the next cell, we render our path at 50% size as an SVG using matplotlib.
262
+
263
+
264
+ ```python
265
+ hv.output(path, backend='matplotlib', fig='svg', size=50)
266
+ ```
267
+
268
+ Passing `hv.output` an object will apply the specified settings only for the subsequent display. If you were to view `path` now in the usual way, you would see that it is still being displayed with Bokeh with purple dotted lines.
269
+
270
+ One thing to note is that when we set the options with `backend='matplotlib'`, the active plotting extension was Bokeh. This means that `opts.Path` will tab complete *bokeh* keywords, and not the matplotlib ones that were specified. In practice you will want to set the backend appropriately before building your options settings, to ensure that you get the most appropriate tab completion.
271
+
272
+ ### Available `hv.output` settings
273
+
274
+ You can see the available settings using `help(hv.output)`. For reference, here are the most commonly used ones:
275
+
276
+ * **backend**: *The backend used by HoloViews*. If the necessary libraries are installed this can be `'bokeh'`, `'matplotlib'` or `'plotly'`.
277
+ * **fig** : *The static figure format*. The most common options are `'svg'` and `'png'`.
278
+ * **holomap**: *The display type for holomaps*. With matplotlib and the necessary support libraries, this may be `'gif'` or `'mp4'`. The JavaScript `'scrubber'` widgets as well as the regular `'widgets'` are always supported.
279
+ * **fps**: *The frames per second used for animations*. This setting is used for GIF output and by the scrubber widget.
280
+ * **size**: *The percentage size of displayed output*. Useful for making all display larger or smaller.
281
+ * **dpi**: *The rendered dpi of the figure*. This setting affects raster output such as PNG images.
282
+
283
+ In `help(hv.output)` you will see a few other, less common settings. The `filename` setting particular is not recommended and will be deprecated in favor of `hv.save` in future.
284
+
285
+ ## Coding style guide
286
+
287
+ Using `hv.output` plus option builders with the `.opts` method and `opts.default` covers the functionality required for most HoloViews code written by users. In addition to these recommended tools, HoloViews supports [Notebook Magics](Notebook_Magics.ipynb) (not recommended because they are Jupyter-specific) and literal (nested dictionary) formats useful for developers, as detailed in the [Extending HoloViews](#Extending-HoloViews) section.
288
+
289
+ This section offers further recommendations for how users can structure their code. These are generally tips based on the important principles described in the [maximizing readability](#Maximizing-readability) section that are often helpful but optional.
290
+
291
+ * Use as few `.opts` calls as necessary to style the object the way you want.
292
+ * You can inline keywords without an option builder if you only have a few common keywords. For instance, `hv.Image(...).opts(cmap='Reds')` is clearer to read than `hv.Image(...).opts(opts.Image(cmap='Reds'))`.
293
+ * Conversely, you *should* use an option builder if you have more than four keywords.
294
+ * When you have multiple option builders, it is often clearest to list them on separate lines with a single indentation in both `.opts` and `opts.defaults`:
295
+
296
+ **Not recommended**
297
+
298
+ ```
299
+ layout.opts(opts.VLine(color='white'), opts.Image(cmap='Reds'), opts.Layout(width=500), opts.Curve(color='blue'))
300
+ ```
301
+
302
+ **Recommended**
303
+
304
+ ```
305
+ layout.opts(
306
+ opts.Curve(color='blue'),
307
+ opts.Image(cmap='Reds'),
308
+ opts.Layout(width=500),
309
+ opts.VLine(color='white'))
310
+ ```
311
+
312
+ * The latter is recommended for another reason: if possible, list your element option builders in alphabetical order, before your container option builders in alphabetical order.
313
+
314
+ * Keep the expression before the `.opts` method simple so that the overall expression is readable.
315
+ * Don't mix `hv.output` and use of the `.opts` method in the same expression.
316
+
317
+ ## What is `.options`?
318
+
319
+
320
+ If you tab complete a HoloViews object, you'll notice there is an `.options` method as well as a `.opts` method. So what is the difference?
321
+
322
+ The `.options` method was introduced in HoloViews 1.10 and was the first time HoloViews allowed users to ignore the distinction between 'style', 'plot' and 'norm' options described in the next section. It is largely equivalent to the `.opts` method except that it applies the options on a returned clone of the object.
323
+
324
+ In other words, you have `clone = obj.options(**kwargs)` where `obj` is unaffected by the keywords supplied while `clone` will be customized. Both `.opts` and `.options` support an explicit `clone` keyword, so:
325
+
326
+ * `obj.opts(**kwargs, clone=True)` is equivalent to `obj.options(**kwargs)`, and conversely
327
+ * `obj.options(**kwargs, clone=False)` is equivalent to `obj.opts(**kwargs)`
328
+
329
+ For this reason, users only ever need to use `.opts` and occasionally supply `clone=True` if required. The only other difference between these methods is that `.opts` supports the full literal specification that allows splitting into [style, plot and norm options](#Split-into-style,-plot-and-norm-options) (for developers) whereas `.options` does not.
330
+
331
+ ## When should I use `clone=True`?
332
+
333
+ The 'Persistent styles' section of the [customization](../getting_started/2-Customization.ipynb) user guide shows how HoloViews remembers options set for an object (per plotting extension). For instance, we never customized the `spikes` object defined at the start of the notebook but we did customize it when it was part of a `Layout` called `layout`. Examining this `spikes` object, we see the options were applied to the underlying object, not just a copy of it in the layout:
334
+
335
+
336
+
337
+ ```python
338
+ spikes
339
+ ```
340
+
341
+ This is because `clone=False` by default in the `.opts` method. To illustrate `clone=True`, let's view some purple spikes *without* affecting the original `spikes` object:
342
+
343
+
344
+ ```python
345
+ purple_spikes = spikes.opts(color='purple', clone=True)
346
+ purple_spikes
347
+ ```
348
+
349
+ Now if you were to look at `spikes` again, you would see it is still looks like the grey version above and only `purple_spikes` is purple. This means that `clone=True` is useful when you want to keep different styles for some HoloViews object (by making styled clones of it) instead of overwriting the options each time you call `.opts`.
350
+
351
+ ## Extending HoloViews
352
+
353
+ In addition to the formats described above for use by users, additional option formats are supported that are less user friendly for data exploration but may be more convenient for library authors building on HoloViews.
354
+
355
+ The first of these is the *`Option` list syntax* which is typically most useful outside of notebooks, a *literal syntax* that avoids the need to import `opts`, and then finally a literal syntax that keeps *style* and *plot* options separate.
356
+
357
+ ### `Option` list syntax
358
+
359
+ If you find yourself using `obj.opts(*options)` where `options` is a list of `Option` objects, use `obj.opts(options)` instead as list input is also supported:
360
+
361
+
362
+ ```python
363
+ options = [
364
+ opts.Curve( height=200, width=900, xaxis=None, line_width=1.50, color='grey', tools=['hover']),
365
+ opts.Spikes(height=150, width=900, yaxis=None, line_width=0.25, color='orange')]
366
+
367
+ layout.opts(options).cols(1)
368
+ ```
369
+
370
+ This approach is often best in regular Python code where you are dynamically building up a list of options to apply. Using the option builders early also allows for early validation before use in the `.opts` method.
371
+
372
+ ### Literal syntax
373
+
374
+ This syntax has the advantage of being a pure Python literal but it is harder to work with directly (due to nested dictionaries), is less readable, lacks tab completion support and lacks validation at the point where the keywords are defined:
375
+
376
+
377
+
378
+ ```python
379
+ layout.opts(
380
+ {'Curve': dict(height=200, width=900, xaxis=None, line_width=2, color='blue', tools=['hover']),
381
+ 'Spikes': dict(height=150, width=900, yaxis=None, line_width=0.25, color='green')}).cols(1)
382
+ ```
383
+
384
+ The utility of this format is you don't need to import `opts` and it is easier to dynamically add or remove keywords using Python or if you are storing options in a text file like YAML or JSON and only later applying them in Python code. This format should be avoided when trying to maximize readability or make the available keyword options easy to explore.
385
+
386
+ ### Using `group` and `label`
387
+
388
+ The notion of an element `group` and `label` was introduced in [Annotating Data](./01-Annotating_Data.ipynb). This type of metadata is helpful for organizing large collections of elements with shared styling, such as automatically generated objects from some external software (e.g. a simulator). If you have a large set of elements with semantically meaningful `group` and `label` parameters set, you can use this information to appropriately customize large numbers of visualizations at once.
389
+
390
+ To illustrate, here are four overlaid curves where three have the `group` of 'Sinusoid' and one of these also has the label 'Squared':
391
+
392
+
393
+ ```python
394
+ xs = np.linspace(-np.pi,np.pi,100)
395
+ curve = hv.Curve((xs, xs/3))
396
+ group_curve1 = hv.Curve((xs, np.sin(xs)), group='Sinusoid')
397
+ group_curve2 = hv.Curve((xs, np.sin(xs+np.pi/4)), group='Sinusoid')
398
+ label_curve = hv.Curve((xs, np.sin(xs)**2), group='Sinusoid', label='Squared')
399
+ curves = curve * group_curve1 * group_curve2 * label_curve
400
+ curves
401
+ ```
402
+
403
+ We can now use the `.opts` method to make all curves blue unless they are in the 'Sinusoid' group in which case they are red. Additionally, if a curve in the 'Sinusoid' group also has the label 'Squared', we can make sure that curve is green with a custom interpolation option:
404
+
405
+
406
+ ```python
407
+ curves.opts(
408
+ opts.Curve(color='blue'),
409
+ opts.Curve('Sinusoid', color='red'),
410
+ opts.Curve('Sinusoid.Squared', interpolation='steps-mid', color='green'))
411
+ ```
412
+
413
+ By using `opts.defaults` instead of the `.opts` method, we can use this type of customization to apply options to many elements, including elements that haven't even been created yet. For instance, if we run:
414
+
415
+
416
+ ```python
417
+ opts.defaults(opts.Area('Error', alpha=0.5, color='grey'))
418
+ ```
419
+
420
+ Then any `Area` element with a `group` of 'Error' will then be displayed as a semi-transparent grey:
421
+
422
+
423
+ ```python
424
+ X = np.linspace(0,2,10)
425
+ hv.Area((X, np.random.rand(10), -np.random.rand(10)), vdims=['y', 'y2'], group='Error')
426
+ ```
427
+
428
+ ## Split into `style`, `plot` and `norm` options
429
+
430
+ In `HoloViews`, an element such as `Curve` actually has three semantic distinct categories of options: `style`, `plot`, and `norm` options. Normally, a user doesn't need to worry about the distinction if they spend most of their time working with a single plotting extension.
431
+
432
+ When trying to build a system that consistently needs to generate visualizations across different plotting libraries, it can be useful to make this distinction explicit:
433
+
434
+ ##### ``style`` options:
435
+
436
+ ``style`` options are passed directly to the underlying rendering backend that actually draws the plots, allowing you to control the details of how it behaves. Each backend has its own options (e.g. the [``bokeh``](Bokeh_Backend) or plotly backends).
437
+
438
+ For whichever backend has been selected, HoloViews can tell you which options are supported, but you will need to read the corresponding documentation (e.g. [matplotlib](http://matplotlib.org/contents.html), [bokeh](http://bokeh.pydata.org)) for the details of their use. For listing available options, see the ``hv.help`` as described in the [Discovering options](#Discovering-options) section.
439
+
440
+ HoloViews has been designed to be easily extensible to additional backends in the future and each backend would have its own set of style options.
441
+
442
+ ##### ``plot`` options:
443
+
444
+ Each of the various HoloViews plotting classes declares various [Parameters](http://param.pyviz.org) that control how HoloViews builds the visualization for that type of object, such as plot sizes and labels. HoloViews uses these options internally; they are not simply passed to the underlying backend. HoloViews documents these options fully in its online help and in the [Reference Manual](http://holoviews.org/Reference_Manual). These options may vary for different backends in some cases, depending on the support available both in that library and in the HoloViews interface to it, but we try to keep any options that are meaningful for a variety of backends the same for all of them. For listing available options, see the output of ``hv.help``.
445
+
446
+ ##### ``norm`` options:
447
+
448
+ ``norm`` options are a special type of plot option that are applied orthogonally to the above two types, to control normalization. Normalization refers to adjusting the properties of one plot relative to those of another. For instance, two images normalized together would appear with relative brightness levels, with the brightest image using the full range black to white, while the other image is scaled proportionally. Two images normalized independently would both cover the full range from black to white. Similarly, two axis ranges normalized together are effectively linked and will expand to fit the largest range of either axis, while those normalized separately would cover different ranges. For listing available options, see the output of ``hv.help``.
449
+
450
+ You can preserve the semantic distinction between these types of option in an augmented form of the [Literal syntax](#Literal-syntax) as follows:
451
+
452
+
453
+ ```python
454
+ full_literal_spec = {
455
+ 'Curve': {'style':dict(color='orange')},
456
+ 'Curve.Sinusoid': {'style':dict(color='grey')},
457
+ 'Curve.Sinusoid.Squared': {'style':dict(color='black'),
458
+ 'plot':dict(interpolation='steps-mid')}}
459
+ hv.opts.apply_groups(curves, full_literal_spec)
460
+ ```
461
+
462
+ This specification is what HoloViews uses internally, but it is awkward for people to use and is not ever recommended for normal users. That said, it does offer the maximal amount of flexibility and power for integration with other software.
463
+
464
+ For instance, a simulator that can output visualization using either Bokeh or Matplotlib via HoloViews could use this format. By keeping the 'plot' and 'style' options separate, the 'plot' options could be set regardless of the plotting library while the 'style' options would be conditional on the backend.
465
+
466
+ ## Onwards
467
+
468
+ This section of the user guide has described how you can discover and set customization options in HoloViews. Using `hv.help` and the option builders, you should be able to find the options available for any given object you want to display.
469
+
470
+ What *hasn't* been explored are some of the facilities HoloViews offers to map the dimensions of your data to style options. This important topic is explored in the next user guide [Style Mapping](04-Style_Mapping.ipynb), where you will learn of the `dim` object as well as about the `Cycle` and `Palette` objects.
hvplot_docs/04-Style_Mapping.md ADDED
@@ -0,0 +1,411 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Style Mapping
2
+
3
+
4
+ ```python
5
+ import numpy as np
6
+ import holoviews as hv
7
+ from holoviews import dim, opts
8
+
9
+ hv.extension('bokeh')
10
+ ```
11
+
12
+ One of the major benefits of HoloViews is the fact that Elements are simple, declarative wrappers around your data, with clearly defined semantics describing how the dimensions of the data map to the screen. Usually the key dimensions (kdims) and value dimensions map to coordinates of the plot axes and/or the colormapped intensity. However there are a huge number of ways to augment the visual representation of an element by mapping dimensions to visual attributes. In this section we will explore how we can declare such mappings including complex transforms specified by so called ``dim`` objects.
13
+
14
+ To illustrate this point let us create a set of three points with x/y-coordinates and alpha, color, marker and size values and then map each of those value dimensions to a visual attribute by name. Note that by default kdims is x,y. However, in this example we also show that the names of the dimensions can be changed and we use 'x values' and 'y values' to represent the data series names.
15
+
16
+
17
+ ```python
18
+ data = {
19
+ 'x values': [0, 1, 0.5],
20
+ 'y values': [1, 0, 0.5],
21
+ 'alpha': [0.5, 1, 0.3],
22
+ 'color': ['red', 'blue', 'green'],
23
+ 'marker': ['circle', 'triangle', 'diamond'],
24
+ 'size': [15, 25, 40]
25
+ }
26
+
27
+ opts.defaults(opts.Points(size=8, line_color='black'))
28
+
29
+ hv.Points(data, kdims=['x values','y values'] , vdims=['alpha', 'color', 'marker', 'size']).opts(
30
+ alpha='alpha', color='color', marker='marker', size='size')
31
+ ```
32
+
33
+ This is the simplest approach to style mapping, dimensions can be mapped to visual attributes directly by name. However often columns in the data will not directly map to a visual property, e.g. we might want to normalize values before mapping them to the alpha, or apply a scaling factor to some values before mapping them to the point size; this is where ``dim`` transforms come in. Below are a few examples of using ``dim`` transforms to map a dimension in the data to the visual style in the plot:
34
+
35
+
36
+ ```python
37
+ points = hv.Points(np.random.rand(400, 4))
38
+
39
+ bins = [0, .25, 0.5, .75, 1]
40
+ labels = ['circle', 'triangle', 'diamond', 'square']
41
+
42
+ layout = hv.Layout([
43
+ points.relabel('Alpha' ).opts(alpha =dim('x').norm()),
44
+ points.relabel('Angle' ).opts(angle =dim('x').norm()*360, marker='dash'),
45
+ points.relabel('Color' ).opts(color =dim('x')),
46
+ points.relabel('Marker').opts(marker=dim('x').bin(bins, labels)),
47
+ points.relabel('Size' ).opts(size =dim('x')*10)
48
+ ])
49
+
50
+ layout.opts(opts.Points(width=250, height=250, xaxis=None, yaxis=None)).cols(5)
51
+ ```
52
+
53
+ ### What are dim transforms?
54
+
55
+ In the above example we saw how to use an ``dim`` to define a transform from a dimension in your data to the visual property on screen. A ``dim`` therefore is a simple way to declare a deferred transform of your data. In the simplest case an ``dim`` simply returns the data for a dimension without transforming it, e.g. to look up the ``'alpha'`` dimension on the points object we can create an ``dim`` and use the ``apply`` method to evaluate the expression:
56
+
57
+
58
+ ```python
59
+ from holoviews import dim
60
+
61
+ ds = hv.Dataset(np.random.rand(10, 4)*10, ['x', 'y'], ['alpha', 'size'])
62
+
63
+ dim('alpha').apply(ds)
64
+ ```
65
+
66
+ #### Mathematical operators
67
+
68
+ An ``dim`` declaration allow arbitrary mathematical operations to be performed, e.g. let us declare that we want to subtract 5 from the 'alpha' dimension and then compute the ``min``:
69
+
70
+
71
+ ```python
72
+ math_op = (dim('alpha')-5).min()
73
+ math_op
74
+ ```
75
+
76
+ Printing the repr of the ``math_op`` we can see that it builds up an nested expression. To see the transform in action we will once again ``apply`` it on the points:
77
+
78
+
79
+ ```python
80
+ math_op.apply(ds)
81
+ ```
82
+
83
+ ``dim`` objects implement most of the NumPy API, supports all standard mathematical operators and also support NumPy ufuncs.
84
+
85
+ #### Custom functions
86
+
87
+ In addition to standard mathematical operators it is also possible to declare custom functions which can be applied by name. By default HoloViews ships with three commonly useful functions.
88
+
89
+ ##### **``norm``**
90
+
91
+ Unity based normalization or features scaling normalizing the values to a range between 0-1 (optionally accepts ``min``/``max`` values as ``limits``, which are usually provided by the plotting system) using the expression:
92
+
93
+ (values - min) / (max-min)
94
+
95
+ for example we can rescale the alpha values into a 0-1 range:
96
+
97
+
98
+ ```python
99
+ dim('alpha').norm().apply(ds)
100
+ ```
101
+
102
+ ##### **``bin``**
103
+
104
+ Bins values using the supplied bins specified as the edges of each bin:
105
+
106
+
107
+ ```python
108
+ bin_op = dim('alpha').bin([0, 5, 10])
109
+
110
+ bin_op.apply(ds)
111
+ ```
112
+
113
+ It is also possible to provide explicit labels for each bin which will replace the bin center value:
114
+
115
+
116
+ ```python
117
+ dim('alpha').bin([0, 5, 10], ['Bin 1', 'Bin 2']).apply(ds)
118
+ ```
119
+
120
+ ##### **``categorize``**
121
+
122
+ Maps a number of discrete values onto the supplied list of categories, e.g. having binned the data into 2 discrete bins we can map them to two discrete marker types 'circle' and 'triangle':
123
+
124
+
125
+ ```python
126
+ dim(bin_op).categorize({2.5: 'circle', 7.5: 'square'}).apply(ds)
127
+ ```
128
+
129
+ This can be very useful to map discrete categories to markers or colors.
130
+
131
+ ### Style mapping with ``dim`` transforms
132
+
133
+ This allows a huge amount of flexibility to express how the data should be mapped to visual style without directly modifying the data. To demonstrate this we will use some of the more complex:
134
+
135
+
136
+ ```python
137
+ points.opts(
138
+ alpha =(dim('x')+0.2).norm(),
139
+ angle =np.sin(dim('y'))*360,
140
+ color =dim('x')**2,
141
+ marker=dim('y').bin(bins, labels),
142
+ size =dim('x')**dim('y')*20, width=500, height=500)
143
+ ```
144
+
145
+ Let's summarize the style transforms we have applied:
146
+
147
+ * **alpha**=``(dim('x')+0.2).norm()``: The alpha are mapped to the x-values offset by 0.2 and normalized.
148
+ * **angle**=``np.sin(dim('x'))*360``: The angle of each marker is the sine of the y-values, multiplied by 360
149
+ * **color**=``'x'``: The points are colormapped by square of their x-values.
150
+ * **marker**=``dim('y').bin(bins, labels)``: The y-values are binned and each bin is assignd a unique marker.
151
+ * **size**=``dim('x')**dim('y')*20``: The size of the points is mapped to the x-values exponentiated with the y-values and scaled by 20
152
+
153
+ These are simply illustrative examples, transforms can be chained in arbitrarily complex ways to achieve almost any mapping from dimension values to visual style.
154
+
155
+ ## Colormapping
156
+
157
+ Color cycles and styles are useful for categorical plots and when overlaying multiple subsets, but when we want to map data values to a color it is better to use HoloViews' facilities for color mapping. Certain image-like types will apply colormapping automatically; e.g. for ``Image``, ``QuadMesh`` or ``HeatMap`` types the first value dimension is automatically mapped to the color. In other cases the values to colormap can be declared by providing a ``color`` style option that specifies which dimension to map into the color value.
158
+
159
+ #### Named colormaps
160
+
161
+ HoloViews accepts colormaps specified either as an explicit list of hex or HTML colors, as a Matplotlib colormap object, or as the name of a bokeh, matplotlib, and colorcet palettes/colormap (which are available when the respective library is imported). The named colormaps available are listed here (suppressing the `_r` versions) and illustrated in detail in the separate [Colormaps](Colormaps.ipynb) user guide:
162
+
163
+
164
+ ```python
165
+ def format_list(l):
166
+ print(' '.join(sorted([k for k in l if not k.endswith('_r')])))
167
+
168
+ format_list(hv.plotting.list_cmaps())
169
+ ```
170
+
171
+ To use one of these colormaps simply refer to it by name with the ``cmap`` style option:
172
+
173
+
174
+ ```python
175
+ ls = np.linspace(0, 10, 400)
176
+ xx, yy = np.meshgrid(ls, ls)
177
+ bounds=(-1,-1,1,1) # Coordinate system: (left, bottom, right, top)
178
+ img = hv.Image(np.sin(xx)*np.cos(yy), bounds=bounds).opts(colorbar=True, width=400)
179
+
180
+ img.relabel('PiYG').opts(cmap='PiYG') + img.relabel('PiYG_r').opts(cmap='PiYG_r')
181
+ ```
182
+
183
+ #### Custom colormaps
184
+
185
+ You can make your own custom colormaps by providing a list of hex colors:
186
+
187
+
188
+ ```python
189
+ img.relabel('Listed colors').opts(cmap=['#0000ff', '#8888ff', '#ffffff', '#ff8888', '#ff0000'], colorbar=True, width=400)
190
+ ```
191
+
192
+ #### Discrete color levels
193
+
194
+ Lastly, existing colormaps can be made discrete by defining an integer number of ``color_levels``:
195
+
196
+
197
+ ```python
198
+ img.relabel('5 color levels').opts(cmap='PiYG', color_levels=5) + img.relabel('11 color levels').opts(cmap='PiYG', color_levels=11)
199
+ ```
200
+
201
+ ### Explicit color mapping
202
+
203
+ 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.
204
+
205
+ #### Continuous values
206
+
207
+ If we provide a continuous value for the ``color`` style option along with a continuous colormap, we can also enable a ``colorbar``:
208
+
209
+
210
+ ```python
211
+ polygons = hv.Polygons([{('x', 'y'): hv.Ellipse(0, 0, (i, i)).array(), 'z': i} for i in range(1, 10)[::-1]], vdims='z')
212
+
213
+ polygons.opts(color='z', colorbar=True, width=380)
214
+ ```
215
+
216
+ #### Categorical values
217
+
218
+ Conversely, when mapping a categorical value into a set of colors, we automatically get a legend (which can be disabled using the ``show_legend`` option):
219
+
220
+
221
+ ```python
222
+ categorical_points = hv.Points((np.random.rand(100),
223
+ np.random.rand(100),
224
+ np.random.choice(list('ABCD'), 100)), vdims='Category')
225
+
226
+ categorical_points.sort('Category').opts(
227
+ color='Category', cmap='Category20', size=8, legend_position='left', width=500)
228
+ ```
229
+
230
+ #### Explicit color mapping
231
+
232
+ Instead of using a listed colormap, you can provide an explicit mapping from category to color. Here we will map the categories 'A', 'B', 'C' and 'D' to specific colors:
233
+
234
+
235
+ ```python
236
+ explicit_mapping = {'A': 'blue', 'B': 'red', 'C': 'green', 'D': 'purple'}
237
+
238
+ categorical_points.sort('Category').opts(color='Category', cmap=explicit_mapping, size=8)
239
+ ```
240
+
241
+ #### Custom color intervals
242
+
243
+ In addition to a simple integer defining the number of discrete levels, the ``color_levels`` option also allows defining a set of custom intervals. This can be useful for defining a fixed scale, such as the Saffir-Simpson hurricane wind scale. Below we declare the color levels along with a list of colors, declaring the scale. Note that the levels define the intervals to map each color to, so if there are N colors we have to define N+1 levels.
244
+
245
+ Having defined the scale we can generate a theoretical hurricane path with wind speed values and use the ``color_levels`` and ``cmap`` to supply the custom color scale:
246
+
247
+
248
+ ```python
249
+ levels = [0, 38, 73, 95, 110, 130, 156, 999]
250
+ colors = ['#5ebaff', '#00faf4', '#ffffcc', '#ffe775', '#ffc140', '#ff8f20', '#ff6060']
251
+
252
+ path = [
253
+ (-75.1, 23.1, 0), (-76.2, 23.8, 0), (-76.9, 25.4, 0), (-78.4, 26.1, 39), (-79.6, 26.2, 39),
254
+ (-80.3, 25.9, 39), (-82.0, 25.1, 74), (-83.3, 24.6, 74), (-84.7, 24.4, 96), (-85.9, 24.8, 111),
255
+ (-87.7, 25.7, 111), (-89.2, 27.2, 131), (-89.6, 29.3, 156), (-89.6, 30.2, 156), (-89.1, 32.6, 131),
256
+ (-88.0, 35.6, 111), (-85.3, 38.6, 96)
257
+ ]
258
+
259
+ hv.Path([path], vdims='Wind Speed').opts(
260
+ color='Wind Speed', color_levels=levels, cmap=colors, line_width=8, colorbar=True, width=450
261
+ )
262
+ ```
263
+
264
+ #### Setting color ranges
265
+
266
+ For an image-like element, color ranges are determined by the range of the `z` value dimension, and they can thus be controlled using the ``.redim.range`` method with `z`. As an example, let's set some values in the image array to NaN and then set the range to clip the data at 0 and 0.9. By declaring the ``clipping_colors`` option we can control what colors are used for NaN values and for values above and below the defined range:
267
+
268
+
269
+ ```python
270
+ clipping = {'min': 'red', 'max': 'green', 'NaN': 'gray'}
271
+ options = dict(cmap='Blues', colorbar=True, width=300, height=230, axiswise=True)
272
+
273
+ arr = np.sin(xx)*np.cos(yy)
274
+ arr[:190, :127] = np.nan
275
+
276
+ original = hv.Image(arr, bounds=bounds).opts(**options)
277
+ colored = original.opts(clipping_colors=clipping, clone=True)
278
+ clipped = colored.redim.range(z=(0, 0.9))
279
+
280
+ original + colored + clipped
281
+ ```
282
+
283
+ 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.
284
+
285
+
286
+ #### Normalization modes
287
+
288
+ 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:
289
+
290
+ * `linear`: Simple linear mapping (used by default)
291
+ * `log`: Logarithmic mapping
292
+ * `eq_hist`: Histogram-equalized mapping
293
+
294
+ 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:
295
+
296
+
297
+ ```python
298
+ np.random.seed(42)
299
+ data = np.random.normal(loc=3, scale=0.3, size=(100,100))
300
+ print("Mean value of random samples is {mean:.3f}, ".format(mean=np.mean(data))
301
+ + "which is much lower\nthan the black square in the center (value 100).")
302
+ data[45:55,45:55] = 100
303
+
304
+ imopts=dict(colorbar=True, xaxis='bare', yaxis='bare', height=160, width=200)
305
+ pattern = hv.Image(data)
306
+
307
+ ( pattern.options(cnorm='linear', title='linear', **imopts)
308
+ + pattern.options(cnorm='log', title='log', **imopts)
309
+ + pattern.options(cnorm='eq_hist', title='eq_hist', **imopts))
310
+ ```
311
+
312
+ 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.
313
+
314
+ 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.
315
+
316
+ 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.
317
+
318
+ 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.
319
+
320
+ ## Other colormapping options
321
+
322
+ * ``clim_percentile``: Percentile value to compute colorscale robust to outliers. If `True`, uses 2nd and 98th percentile; otherwise uses the specified percentile value.
323
+ * ``cnorm``: Color normalization to be applied during colormapping. Allows switching between 'linear', 'log', and 'eq_hist'.
324
+ * ``logz``: Enable logarithmic color scale (same as `cnorm='log'`; to be deprecated at some point)
325
+ * ``symmetric``: Ensures that the color scale is centered on zero (e.g. ``symmetric=True``)
326
+
327
+ ## Cycles and Palettes
328
+
329
+ Frequently we want to plot multiple subsets of data, which is made easy by using ``Overlay`` and ``NdOverlay`` objects. When overlaying multiple elements of the same type they will need to be distinguished visually, and HoloViews provides two mechanisms for styling the different subsets automatically in those cases:
330
+
331
+ * ``Cycle``: A Cycle defines a list of discrete styles
332
+ * ``Palette``: A Palette defines a continuous color space which will be sampled discretely
333
+
334
+ ### Cycle
335
+
336
+ A ``Cycle`` can be applied to any of the style options on an element. By default, most elements define a ``Cycle`` on the color property. Here we will create an overlay of three ``Points`` objects using the default cycles, then display it using the default cycles along with a copy where we changed the dot color and size using a custom ``Cycle``:
337
+
338
+
339
+ ```python
340
+ points = (
341
+ hv.Points(np.random.randn(50, 2) ) *
342
+ hv.Points(np.random.randn(50, 2) + 1 ) *
343
+ hv.Points(np.random.randn(50, 2) * 0.5)
344
+ )
345
+
346
+ color_cycle = hv.Cycle(['red', 'green', 'blue'])
347
+ points + points.opts(opts.Points(color=color_cycle), clone=True)
348
+ ```
349
+
350
+ Here color has been changed to cycle over the three provided colors, while size has been specified as a constant (though a cycle like `hv.Cycle([2,5,10])` could just as easily have been used for the size as well).
351
+
352
+ #### Defaults
353
+
354
+ In addition to defining custom color cycles by explicitly defining a list of colors, ``Cycle`` also defines a list of default Cycles generated from bokeh Palettes and matplotlib colormaps:
355
+
356
+
357
+ ```python
358
+ format_list(hv.Cycle.default_cycles.keys())
359
+ ```
360
+
361
+ (Here some of these Cycles have a reversed variant ending in `_r` that is not shown.)
362
+
363
+ To use one of these default Cycles simply construct the Cycle with the corresponding key:
364
+
365
+
366
+ ```python
367
+ xs = np.linspace(0, np.pi*2)
368
+ curves = hv.Overlay([hv.Curve(np.sin(xs+p)) for p in np.linspace(0, np.pi, 10)])
369
+
370
+ curves.opts(opts.Curve(color=hv.Cycle('Category20'), width=600))
371
+ ```
372
+
373
+ #### Markers and sizes
374
+
375
+ The above examples focus on color Cycles, but Cycles may be used to define any style option. Here let's use them to cycle over a number of marker styles and sizes, which will be expanded by cycling over each item independently. In this case we are cycling over three Cycles, resulting in the following style combinations:
376
+
377
+ 1. ``{'color': '#30a2da', 'marker': 'x', 'size': 10}``
378
+ 2. ``{'color': '#fc4f30', 'marker': '^', 'size': 5}``
379
+ 3. ``{'color': '#e5ae38', 'marker': '+', 'size': 10}``
380
+
381
+
382
+ ```python
383
+ color = hv.Cycle(['#30a2da', '#fc4f30', '#e5ae38'])
384
+ markers = hv.Cycle(['x', '^', '+'])
385
+ sizes = hv.Cycle([10, 5])
386
+ points.opts(opts.Points(line_color=color, marker=markers, size=sizes))
387
+ ```
388
+
389
+ ### Palettes
390
+
391
+ Palettes are similar to cycles, but treat a set of colors as a continuous colorspace to be sampled at regularly spaced intervals. Again they are made automatically available from existing colormaps (with `_r` versions also available):
392
+
393
+
394
+ ```python
395
+ format_list(hv.Palette.colormaps.keys())
396
+ ```
397
+
398
+ (Here each colormap `X` has a corresponding version `X_r` with the values reversed; the `_r` variants are suppressed above.)
399
+
400
+ As a simple example we will create a Palette from the Spectral colormap and apply it to an Overlay of 6 Ellipses. Comparing it to the Spectral ``Cycle`` we can immediately see that the Palette covers the entire color space spanned by the Spectral colormap, while the Cycle instead uses the first 6 colors of the Spectral colormap:
401
+
402
+
403
+ ```python
404
+ ellipses = hv.Overlay([hv.Ellipse(0, 0, s) for s in range(6)])
405
+
406
+ ellipses.relabel('Palette').opts(opts.Ellipse(color=hv.Palette('Spectral'), line_width=5), clone=True) +\
407
+ ellipses.relabel('Cycle' ).opts(opts.Ellipse(color=hv.Cycle( 'Spectral'), line_width=5), clone=True)
408
+ ```
409
+
410
+ Thus if you want to have have a discrete set of distinguishable colors starting from a list of colors that vary slowly and continuously, you should usually supply it as a Palette, not a Cycle. Conversely, you should use a Cycle when you want to iterate through a specific list of colors, in order, without skipping around the list like a Palette will.
411
+
hvplot_docs/kwargs.md ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Generic options
2
+ ---------------
3
+ autorange (default=None): Literal['x', 'y'] | None
4
+ Whether to enable auto-ranging along the x- or y-axis when
5
+ zooming. Requires HoloViews >= 1.16.
6
+ clim: tuple
7
+ Lower and upper bound of the color scale
8
+ cnorm (default='linear'): str
9
+ Color scaling which must be one of 'linear', 'log' or 'eq_hist'
10
+ colorbar (default=False): boolean
11
+ Enables a colorbar
12
+ fontscale: number
13
+ Scales the size of all fonts by the same amount, e.g. fontscale=1.5
14
+ enlarges all fonts (title, xticks, labels etc.) by 50%
15
+ fontsize: number or dict
16
+ Set title, label and legend text to the same fontsize. Finer control
17
+ by using a dict: {'title': '15pt', 'ylabel': '5px', 'ticks': 20}
18
+ flip_xaxis/flip_yaxis: boolean
19
+ Whether to flip the axis left to right or up and down respectively
20
+ grid (default=False): boolean
21
+ Whether to show a grid
22
+ hover : boolean
23
+ Whether to show hover tooltips, default is True unless datashade is
24
+ True in which case hover is False by default
25
+ hover_cols (default=[]): list or str
26
+ Additional columns to add to the hover tool or 'all' which will
27
+ includes all columns (including indexes if use_index is True).
28
+ invert (default=False): boolean
29
+ Swaps x- and y-axis
30
+ frame_width/frame_height: int
31
+ The width and height of the data area of the plot
32
+ legend (default=True): boolean or str
33
+ Whether to show a legend, or a legend position
34
+ ('top', 'bottom', 'left', 'right')
35
+ logx/logy (default=False): boolean
36
+ Enables logarithmic x- and y-axis respectively
37
+ logz (default=False): boolean
38
+ Enables logarithmic colormapping
39
+ loglog (default=False): boolean
40
+ Enables logarithmic x- and y-axis
41
+ max_width/max_height: int
42
+ The maximum width and height of the plot for responsive modes
43
+ min_width/min_height: int
44
+ The minimum width and height of the plot for responsive modes
45
+ padding: number or tuple
46
+ Fraction by which to increase auto-ranged extents to make
47
+ datapoints more visible around borders. Supports tuples to
48
+ specify different amount of padding for x- and y-axis and
49
+ tuples of tuples to specify different amounts of padding for
50
+ upper and lower bounds.
51
+ rescale_discrete_levels (default=True): boolean
52
+ If `cnorm='eq_hist'` and there are only a few discrete values,
53
+ then `rescale_discrete_levels=True` (the default) decreases
54
+ the lower limit of the autoranged span so that the values are
55
+ rendering towards the (more visible) top of the `cmap` range,
56
+ thus avoiding washout of the lower values. Has no effect if
57
+ `cnorm!=`eq_hist`.
58
+ responsive: boolean
59
+ Whether the plot should responsively resize depending on the
60
+ size of the browser. Responsive mode will only work if at
61
+ least one dimension of the plot is left undefined, e.g. when
62
+ width and height or width and aspect are set the plot is set
63
+ to a fixed size, ignoring any responsive option.
64
+ rot: number
65
+ Rotates the axis ticks along the x-axis by the specified
66
+ number of degrees.
67
+ shared_axes (default=True): boolean
68
+ Whether to link axes between plots
69
+ transforms (default={}): dict
70
+ A dictionary of HoloViews dim transforms to apply before plotting
71
+ title (default=''): str
72
+ Title for the plot
73
+ tools (default=[]): list
74
+ List of tool instances or strings (e.g. ['tap', 'box_select'])
75
+ xaxis/yaxis: str or None
76
+ Whether to show the x/y-axis and whether to place it at the
77
+ 'top'/'bottom' and 'left'/'right' respectively.
78
+ xformatter/yformatter (default=None): str or TickFormatter
79
+ Formatter for the x-axis and y-axis (accepts printf formatter,
80
+ e.g. '%.3f', and bokeh TickFormatter)
81
+ xlabel/ylabel/clabel (default=None): str
82
+ Axis labels for the x-axis, y-axis, and colorbar
83
+ xlim/ylim (default=None): tuple or list
84
+ Plot limits of the x- and y-axis
85
+ xticks/yticks (default=None): int or list
86
+ Ticks along x- and y-axis specified as an integer, list of
87
+ ticks positions, or list of tuples of the tick positions and labels
88
+ width (default=700)/height (default=300): int
89
+ The width and height of the plot in pixels
90
+ attr_labels (default=None): bool
91
+ Whether to use an xarray object's attributes as labels, defaults to
92
+ None to allow best effort without throwing a warning. Set to True
93
+ to see warning if the attrs can't be found, set to False to disable
94
+ the behavior.
95
+ sort_date (default=True): bool
96
+ Whether to sort the x-axis by date before plotting
97
+ symmetric (default=None): bool
98
+ Whether the data are symmetric around zero. If left unset, the data
99
+ will be checked for symmetry as long as the size is less than
100
+ ``check_symmetric_max``.
101
+ check_symmetric_max (default=1000000):
102
+ Size above which to stop checking for symmetry by default on the data.
103
+
104
+ Resampling options
105
+ ------------------
106
+ aggregator (default=None):
107
+ Aggregator to use when applying rasterize or datashade operation
108
+ (valid options include 'mean', 'count', 'min', 'max' and more, and
109
+ datashader reduction objects)
110
+ dynamic (default=True):
111
+ Whether to return a dynamic plot which sends updates on widget and
112
+ zoom/pan events or whether all the data should be embedded
113
+ (warning: for large groupby operations embedded data can become
114
+ very large if dynamic=False)
115
+ datashade (default=False):
116
+ Whether to apply rasterization and shading (colormapping) using
117
+ the Datashader library, returning an RGB object instead of
118
+ individual points
119
+ downsample (default=False):
120
+ Whether to apply LTTB (Largest Triangle Three Buckets)
121
+ downsampling to the element (note this is only well behaved for
122
+ timeseries data). Requires HoloViews >= 1.16.
123
+ dynspread (default=False):
124
+ For plots generated with datashade=True or rasterize=True,
125
+ automatically increase the point size when the data is sparse
126
+ so that individual points become more visible
127
+ rasterize (default=False):
128
+ Whether to apply rasterization using the Datashader library,
129
+ returning an aggregated Image (to be colormapped by the
130
+ plotting backend) instead of individual points
131
+ resample_when (default=None):
132
+ Applies a resampling operation (datashade, rasterize or downsample) if
133
+ the number of individual data points present in the current zoom range
134
+ is above this threshold. The raw plot is displayed otherwise.
135
+ x_sampling/y_sampling (default=None):
136
+ Specifies the smallest allowed sampling interval along the x/y axis.
137
+
138
+ Geographic options
139
+ ------------------
140
+ coastline (default=False):
141
+ Whether to display a coastline on top of the plot, setting
142
+ coastline='10m'/'50m'/'110m' specifies a specific scale.
143
+ crs (default=None):
144
+ Coordinate reference system of the data specified as Cartopy
145
+ CRS object, proj.4 string or EPSG code.
146
+ features (default=None): dict or list
147
+ A list of features or a dictionary of features and the scale
148
+ at which to render it. Available features include 'borders',
149
+ 'coastline', 'lakes', 'land', 'ocean', 'rivers' and 'states'.
150
+ Available scales include '10m'/'50m'/'110m'.
151
+ geo (default=False):
152
+ Whether the plot should be treated as geographic (and assume
153
+ PlateCarree, i.e. lat/lon coordinates).
154
+ global_extent (default=False):
155
+ Whether to expand the plot extent to span the whole globe.
156
+ project (default=False):
157
+ Whether to project the data before plotting (adds initial
158
+ overhead but avoids projecting data when plot is dynamically
159
+ updated).
160
+ projection (default=None): str or Cartopy CRS
161
+ Coordinate reference system of the plot specified as Cartopy
162
+ CRS object or class name.
163
+ tiles (default=False):
164
+ Whether to overlay the plot on a tile source. Tiles sources
165
+ can be selected by name or a tiles object or class can be passed,
166
+ the default is 'Wikipedia'.