lets_plot.geom_ydotplot¶
- lets_plot.geom_ydotplot(mapping=None, *, data=None, stat=None, position=None, show_legend=None, sampling=None, tooltips=None, binwidth=None, bins=None, method=None, stackdir=None, stackratio=None, dotsize=None, stackgroups=None, center=None, boundary=None, **other_args)¶
Dotplot represents individual observations in a batch of data with circular dots. The diameter of a dot corresponds to the maximum width or bin width, depending on the binning algorithm. geom_ydotplot() is an obvious blend of geom_violin() and geom_dotplot().
- 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 DataFrame 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=’ydotplot’
The statistical transformation to use on the data for this layer, as a string. Supported transformations: ‘identity’ (leaves the data unchanged), ‘ydotplot’ (depends on method parameter).
- show_legendbool, default=True
False - do not show legend for this layer.
- samplingFeatureSpec
Result of the call to the sampling_xxx() function. Value None (or ‘none’) will disable sampling for this layer.
- tooltipslayer_tooltips
Result of the call to the layer_tooltips() function. Specifies appearance, style and content.
- binwidthfloat
When method is ‘dotdensity’, this specifies maximum bin width. When method is ‘histodot’, this specifies bin width.
- binsint, default=30
When method is ‘histodot’, this specifies number of bins. Overridden by binwidth.
- method{‘dotdensity’, ‘histodot’}, default=’dotdensity’
Use ‘dotdensity’ for dot-density binning, or ‘histodot’ for fixed bin widths (like in geom_histogram).
- stackdir{‘left’, ‘right’, ‘center’, ‘centerwhole’}, default=’center’
Which direction to stack the dots.
- stackratiofloat, default=1.0
How close to stack the dots. Use smaller values for closer, overlapping dots.
- dotsizefloat, default=1.0
The diameter of the dots relative to binwidth.
- stackgroupsbool, default=False
Separates overlapping stack groups when stackgroups=False. Overlaps stack groups when method=’dotdensity’ and stackgroups=True. Stacks dots across groups when method=’histodot’ and stackgroups=True.
- centerfloat
When method is ‘histodot’, this specifies x-value to align bin centers to.
- boundaryfloat
When method is ‘histodot’, this specifies x-value to align bin boundary (i.e. point between bins) to.
- 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
With ‘dotdensity’ binning, the bin positions are determined by the data and binwidth, which is the maximum width of each bin. With ‘histodot’ binning, the bins have fixed positions and fixed widths, much like a histogram.
Computed variables:
..count.. : number of points with y-axis coordinate in the same bin.
..binwidth.. : max width of each bin if method is ‘dotdensity’; width of each bin if method is ‘histodot’.
geom_ydotplot() understands the following aesthetics mappings:
x : x-axis value.
y : y-axis value.
alpha : transparency level of a layer. Understands numbers between 0 and 1.
color (colour) : color of a geometry lines. Can be continuous or discrete. For continuous value this will be a color gradient between two colors.
fill : color of geometry filling.
Examples
1import numpy as np 2from lets_plot import * 3LetsPlot.setup_html() 4np.random.seed(42) 5n = 100 6x = np.random.choice(['A', 'B'], size=n) 7y = np.random.normal(size=n) 8ggplot({'x': x, 'y': y}, aes('x', 'y')) + geom_ydotplot()