lets_plot.geom_dotplot#
- lets_plot.geom_dotplot(mapping=None, *, data=None, show_legend=None, manual_key=None, sampling=None, tooltips=None, binwidth=None, bins=None, method=None, stackdir=None, stackratio=None, dotsize=None, stackgroups=None, center=None, boundary=None, color_by=None, fill_by=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.
- 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.
- show_legendbool, default=True
False - do not show legend for this layer.
- 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.
- 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{‘up’, ‘down’, ‘center’, ‘centerwhole’}, default=’up’
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
Stack dots across groups when method=’histodot’.
- 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.
- 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
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 x-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_dotplot() understands the following aesthetics mappings:
x : x-axis value.
alpha : transparency level of a layer. Accept values between 0 and 1.
color (colour) : color of the geometry lines. For more info see https://lets-plot.org/python/pages/aesthetics.html#color-and-fill.
fill : fill color. For more info see https://lets-plot.org/python/pages/aesthetics.html#color-and-fill.
stroke : width of the dot border.
Examples
1import numpy as np 2from lets_plot import * 3LetsPlot.setup_html() 4np.random.seed(42) 5data = {'x': np.random.normal(size=100)} 6ggplot(data, aes(x='x')) + geom_dotplot()
1import numpy as np 2from lets_plot import * 3LetsPlot.setup_html() 4np.random.seed(42) 5data = {'x': np.random.gamma(2.0, size=100)} 6ggplot(data, aes(x='x')) + \ 7 geom_dotplot(aes(color='x', fill='x'), \ 8 binwidth=.2, method='histodot', boundary=0.0)
1import numpy as np 2from lets_plot import * 3LetsPlot.setup_html() 4np.random.seed(42) 5data = {'x': np.random.normal(size=100)} 6ggplot(data, aes(x='x')) + \ 7 geom_dotplot(binwidth=.2, stackdir='centerwhole', \ 8 stackratio=1.2, color='black', fill='gray')