lets_plot.geom_ydotplot#

lets_plot.geom_ydotplot(mapping=None, *, data=None, show_legend=None, sampling=None, tooltips=None, orientation=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. 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 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.

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.

orientationstr

Specify the axis that the layer’s stat and geom should run along. The default value (None) automatically determines the orientation based on the aesthetic mapping. If the automatic detection doesn’t work, it can be set explicitly by specifying the ‘x’ or ‘y’ orientation.

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

Separate overlapping stack groups when stackgroups=False. Overlap stack groups when method=’dotdensity’ and stackgroups=True. Stack 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.

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 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. Accept values between 0 and 1.

  • color (colour) : color of the geometry lines. String in the following formats: RGB/RGBA (e.g. “rgb(0, 0, 255)”); HEX (e.g. “#0000FF”); color name (e.g. “red”); role name (“pen”, “paper” or “brush”).

  • fill : fill color. String in the following formats: RGB/RGBA (e.g. “rgb(0, 0, 255)”); HEX (e.g. “#0000FF”); color name (e.g. “red”); role name (“pen”, “paper” or “brush”).

  • stroke : width of the dot border.

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()

 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.gamma(0.75, size=n)
 8ggplot({'x': x, 'y': y}, aes('x', 'y')) + \
 9    geom_ydotplot(aes(fill='x'), color='black', \
10                  binwidth=.15, method='histodot', \
11                  boundary=0.0, dotsize=.75)

 1import numpy as np
 2from lets_plot import *
 3LetsPlot.setup_html()
 4np.random.seed(42)
 5n = 100
 6x = np.random.choice(['A', 'B', 'C'], size=n)
 7y = np.random.normal(size=n)
 8ggplot({'x': x, 'y': y}, aes('x', 'y')) + \
 9    geom_ydotplot(color='black', fill='#d7191c', \
10                  method='dotdensity', binwidth=.2,
11                  stackdir='left', stackratio=.8) + \
12    geom_ydotplot(color='black', fill='#2c7bb6', \
13                  method='histodot', binwidth=.2, \
14                  stackdir='right', stackratio=.8)