geom_area_ridges#
- geom_area_ridges(mapping=None, *, data=None, stat=None, position=None, show_legend=None, inherit_aes=None, manual_key=None, sampling=None, tooltips=None, trim=None, tails_cutoff=None, kernel=None, adjust=None, bw=None, n=None, fs_max=None, min_height=None, scale=None, quantiles=None, quantile_lines=None, color_by=None, fill_by=None, **other_args)#
Plot the sum of the y and height aesthetics versus x. Heights of the ridges are relatively scaled.
- Parameters:
- mappingFeatureSpec
Set of aesthetic mappings created by aes() function. Aesthetic mappings describe the way that variables in the data are mapped to plot “aesthetics”.
- datadict or Pandas or Polars DataFrame
The data to be displayed in this layer. If None, the default, the data is inherited from the plot data as specified in the call to ggplot.
- statstr, default=’densityridges’
The statistical transformation to use on the data for this layer, as a string. Supported transformations: ‘identity’ (leaves the data unchanged), ‘densityridges’ (computes and draws kernel density estimate for each ridge).
- positionstr or FeatureSpec, default=’identity’
Position adjustment. Either a position adjustment name: ‘dodge’, ‘dodgev’, ‘jitter’, ‘nudge’, ‘jitterdodge’, ‘fill’, ‘stack’ or ‘identity’, or the result of calling a position adjustment function (e.g., position_dodge() etc.).
- show_legendbool, default=True
False - do not show legend for this layer.
- inherit_aesbool, default=True
False - do not combine the layer aesthetic mappings with the plot shared mappings.
- manual_keystr or layer_key
The key to show in the manual legend. Specify text for the legend label or advanced settings using the layer_key() function.
- samplingFeatureSpec
Result of the call to the sampling_xxx() function. To prevent any sampling for this layer pass value “none” (string “none”).
- tooltipslayer_tooltips
Result of the call to the layer_tooltips() function. Specify appearance, style and content. Set tooltips=’none’ to hide tooltips from the layer.
- trimbool, default=False
Trim the tails of the ridges to the range of the data.
- tails_cutofffloat
Extend domain of each ridge on tails_cutoff * bw if trim=False. tails_cutoff=None (default) extends domain to maximum (domain overall ridges).
- kernelstr, default=’gaussian’
The kernel we use to calculate the density function. Choose among ‘gaussian’, ‘cosine’, ‘optcosine’, ‘rectangular’ (or ‘uniform’), ‘triangular’, ‘biweight’ (or ‘quartic’), ‘epanechikov’ (or ‘parabolic’).
- bwstr or float
The method (or exact value) of bandwidth. Either a string (choose among ‘nrd0’ and ‘nrd’), or a float.
- adjustfloat
Adjust the value of bandwidth by multiplying it. Change how smooth the frequency curve is.
- nint, default=512
The number of sampled points for plotting the function.
- fs_maxint, default=500
Maximum size of data to use density computation with ‘full scan’. For bigger data, less accurate but more efficient density computation is applied.
- min_heightfloat, default=0.0
A height cutoff on the drawn ridges. All values that fall below this cutoff will be removed.
- scalefloat, default=1.0
A multiplicative factor applied to height aesthetic. If scale = 1.0, the heights of a ridges are automatically scaled such that the ridge with height = 1.0 just touches the one above.
- quantileslist of float, default=[0.25, 0.5, 0.75]
Draw vertical lines at the given quantiles of the density estimate.
- quantile_linesbool, default=False
Show the quantile lines.
- color_by{‘fill’, ‘color’, ‘paint_a’, ‘paint_b’, ‘paint_c’}, default=’color’
Define the color aesthetic for the geometry.
- fill_by{‘fill’, ‘color’, ‘paint_a’, ‘paint_b’, ‘paint_c’}, default=’fill’
Define the fill aesthetic for the geometry.
- other_args
Other arguments passed on to the layer. These are often aesthetics settings used to set an aesthetic to a fixed value, like color=’red’, fill=’blue’, size=3 or shape=21. They may also be parameters to the paired geom/stat.
- Returns:
- LayerSpec
Geom object specification.
Notes
Computed variables:
..height.. : density scaled for the ridges, according to area, counts or to a constant maximum height.
..density.. : density estimate.
..count.. : density * number of points.
..scaled.. : density estimate, scaled to maximum of 1.
..quantile.. : quantile estimate.
geom_area_ridges() understands the following aesthetics mappings:
x : x-axis coordinates.
y : y-axis coordinates.
height : height of the ridge. Assumed to be between 0 and 1, though this is not required.
alpha : transparency level of a layer. Accept values between 0 and 1.
color (colour) : color of the geometry lines. For more info see Color and Fill.
fill : fill color. For more info see Color and Fill.
size : lines width.
linetype : type of the line of border. Accept codes or names (0 = ‘blank’, 1 = ‘solid’, 2 = ‘dashed’, 3 = ‘dotted’, 4 = ‘dotdash’, 5 = ‘longdash’, 6 = ‘twodash’), a hex string (up to 8 digits for dash-gap lengths), or a list pattern [offset, [dash, gap, …]] / [dash, gap, …]. For more info see Line Types.
weight : used by ‘densityridges’ stat to compute weighted density.
quantile : quantile values to draw quantile lines and fill quantiles of the geometry by color.
To hide axis tooltips, set ‘blank’ or the result of element_blank() to the axis_tooltip or axis_tooltip_x parameter of the theme().
Examples
1import numpy as np 2from lets_plot import * 3LetsPlot.setup_html() 4n, m = 10, 3 5np.random.seed(42) 6x = np.random.normal(size=n*m) 7y = np.repeat(np.arange(m), n) 8ggplot({'x': x, 'y': y}, aes('x', 'y')) + \ 9 geom_area_ridges()
1from lets_plot import * 2LetsPlot.setup_html() 3data = { 4 "x": [1, 2, 3, 4, 5, 6], 5 "y": ['a', 'a', 'a', 'a', 'a', 'a'], 6 "h": [1, -2, 3, -4, 5, 4], 7} 8ggplot(data) + \ 9 geom_area_ridges(aes("x", "y", height="h"), \ 10 stat='identity', min_height=-2, \ 11 color="#756bb1", fill="#bcbddc")
1import numpy as np 2from lets_plot import * 3LetsPlot.setup_html() 4n, m = 50, 3 5np.random.seed(42) 6x = np.random.normal(size=n*m) 7y = np.repeat(['a', 'b', 'c'], n) 8ggplot({'x': x, 'y': y}, aes('x', 'y')) + \ 9 geom_area_ridges(aes(fill='..quantile..'), \ 10 quantiles=[.05, .25, .5, .75, .95], quantile_lines=True, \ 11 scale=1.5, kernel='triangular', color='black')