Spaces:
Running
Running
File size: 8,812 Bytes
b9a0f21 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
```python
import hvplot
import hvplot.pandas # noqa
```
The hvPlot API is closely modeled on the pandas plot API but also diverges in certain cases, either to improve consistency or to provide additional functionality. This section will outline the valid options to control the axes of a plot, to control datashading and to modify the style of a plot. To look these options up interactively you may either use the tab-completion machinery in IPython or the Jupyter notebook, e.g.:
```python
df.hvplot.line(<TAB>
```
OR use the help method:
```
hvplot.help('line')
```
## Generic options
The generic set of options which may apply to all plot types include:
clim: tuple
Lower and upper bound of the color scale
cnorm (default='linear'): str
Color scaling which must be one of 'linear', 'log' or 'eq_hist'
colorbar (default=False): boolean
Enables a colorbar
fontscale: number
Scales the size of all fonts by the same amount, e.g. fontscale=1.5
enlarges all fonts (title, xticks, labels etc.) by 50%
fontsize: number or dict
Set title, label and legend text to the same fontsize. Finer control
by using a dict: {'title': '15pt', 'ylabel': '5px', 'ticks': 20}
flip_xaxis/flip_yaxis: boolean
Whether to flip the axis left to right or up and down respectively
grid (default=False): boolean
Whether to show a grid
hover : boolean
Whether to show hover tooltips, default is True unless datashade is
True in which case hover is False by default
hover_cols (default=[]): list or str
Additional columns to add to the hover tool or 'all' which will
includes all columns (including indexes if use_index is True).
invert (default=False): boolean
Swaps x- and y-axis
frame_width/frame_height: int
The width and height of the data area of the plot
legend (default=True): boolean or str
Whether to show a legend, or a legend position
('top', 'bottom', 'left', 'right')
logx/logy (default=False): boolean
Enables logarithmic x- and y-axis respectively
logz (default=False): boolean
Enables logarithmic colormapping
loglog (default=False): boolean
Enables logarithmic x- and y-axis
max_width/max_height: int
The maximum width and height of the plot for responsive modes
min_width/min_height: int
The minimum width and height of the plot for responsive modes
padding: number or tuple
Fraction by which to increase auto-ranged extents to make
datapoints more visible around borders. Supports tuples to
specify different amount of padding for x- and y-axis and
tuples of tuples to specify different amounts of padding for
upper and lower bounds.
responsive: boolean
Whether the plot should responsively resize depending on the
size of the browser. Responsive mode will only work if at
least one dimension of the plot is left undefined, e.g. when
width and height or width and aspect are set the plot is set
to a fixed size, ignoring any responsive option.
rot: number
Rotates the axis ticks along the x-axis by the specified
number of degrees.
shared_axes (default=True): boolean
Whether to link axes between plots
transforms (default={}): dict
A dictionary of HoloViews dim transforms to apply before plotting
title (default=''): str
Title for the plot
tools (default=[]): list
List of tool instances or strings (e.g. ['tap', box_select'])
xaxis/yaxis: str or None
Whether to show the x/y-axis and whether to place it at the
'top'/'bottom' and 'left'/'right' respectively.
xformatter/yformatter (default=None): str or TickFormatter
Formatter for the x-axis and y-axis (accepts printf formatter,
e.g. '%.3f', and bokeh TickFormatter)
xlabel/ylabel/clabel (default=None): str
Axis labels for the x-axis, y-axis, and colorbar
xlim/ylim (default=None): tuple or list
Plot limits of the x- and y-axis
xticks/yticks (default=None): int or list
Ticks along x- and y-axis specified as an integer, list of
ticks positions, or list of tuples of the tick positions and labels
width (default=700)/height (default=300): int
The width and height of the plot in pixels
attr_labels (default=None): bool
Whether to use an xarray object's attributes as labels, defaults to
None to allow best effort without throwing a warning. Set to True
to see warning if the attrs can't be found, set to False to disable
the behavior.
sort_date (default=True): bool
Whether to sort the x-axis by date before plotting
symmetric (default=None): bool
Whether the data are symmetric around zero. If left unset, the data
will be checked for symmetry as long as the size is less than
``check_symmetric_max``.
check_symmetric_max (default=1000000):
Size above which to stop checking for symmetry by default on the data.
## Datashading options
In addition to regular plot options hvplot also exposes options for dealing with large data:
aggregator (default=None):
Aggregator to use when applying rasterize or datashade operation
(valid options include 'mean', 'count', 'min', 'max' and more, and
datashader reduction objects)
dynamic (default=True):
Whether to return a dynamic plot which sends updates on widget and
zoom/pan events or whether all the data should be embedded
(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
dynspread (default=False):
Allows plots generated with datashade=True to increase the point
size to make sparse regions more visible
rasterize (default=False):
Whether to apply rasterization using the datashader library
returning an aggregated Image
x_sampling/y_sampling (default=None):
Specifies the smallest allowed sampling interval along the x/y axis.
## Geographic options
When dealing with geographic data, there are a number of options that become available. See the [geographic section](Geographic_Data.ipynb) for more information on working with geographic data:
coastline (default=False):
Whether to display a coastline on top of the plot, setting
coastline='10m'/'50m'/'110m' specifies a specific scale.
crs (default=None):
Coordinate reference system of the data specified as Cartopy
CRS object, proj.4 string or EPSG code.
features (default=None): dict or list
A list of features or a dictionary of features and the scale
at which to render it. Available features include 'borders',
'coastline', 'lakes', 'land', 'ocean', 'rivers' and 'states'.
Available scales include '10m'/'50m'/'110m'.
geo (default=False):
Whether the plot should be treated as geographic (and assume
PlateCarree, i.e. lat/lon coordinates).
global_extent (default=False):
Whether to expand the plot extent to span the whole globe.
project (default=False):
Whether to project the data before plotting (adds initial
overhead but avoids projecting data when plot is dynamically
updated).
tiles (default=False):
Whether to overlay the plot on a tile source. Tiles sources
can be selected by name or a tiles object or class can be passed,
the default is 'Wikipedia'.
## Kind options
Each type of plot may have a number of options to visual attributes specific to that plot type. In general these are provided in the docstring of the plot type, which can be viewed using ``help`` method:
```python
hvplot.help('scatter', generic=False, style=False)
```
## Styling options
Beyond the options specific to each plot type (or ``kind``) it is also possible to customize each component in detail, exposing all the options bokeh exposes. These usually include options to color the line and fill color, alpha and style. To see the full listing we can once again use the ``help`` method:
```python
hvplot.help('line', docstring=False, generic=False)
```
In general, the objects returned by hvPlot are regular HoloViews objects, which can be overlaid, laid out, composed and customized like all other HoloViews objects. The [HoloViews](https://holoviews.org) website explains all the functionality available, but what's on this hvPlot website should be enough to get you up and running for typical usage.
|