API Reference#
For an overview of all the main functions in one notebook, see the Lets-Plot cheatbook.
Configuring#
Initialize the library and its options. |
Plotting#
A class of the initial plot object. |
Create a new ggplot plot. |
|
Collection of plots created by ggplot function. |
|
Combine several plots on one figure, organized in a regular grid. |
|
Convert a given geometry layer to a marginal layer. |
|
Add a toolbar to a chart. |
|
Define aesthetic mappings. |
|
Export plot or bunch to a file. |
Geometries#
Standard Geometries#
Draw points defined by an x and y coordinate, as for a scatter plot. |
|
Connect observations in the order, how they appear in the data. |
|
Connect points in the order of the variable on the x axis. |
|
Add a smoothed conditional mean. |
|
Display a bar chart which makes the height of the bar proportional to the number of observed variable values, mapped to x axis. |
|
Sum unique values. |
|
Draw pie chart. |
|
Draw lollipop chart. |
|
Display a 1d distribution by dividing variable mapped to x axis into bins and counting the number of observations in each bin. |
|
Dotplot represents individual observations in a batch of data with circular dots. |
|
Apply a rectangular grid to the plane, count observations in each cell (bin) of the grid, and map the count to the fill color of the cell (tile). |
|
Display rectangles with x, y values mapped to the center of the tile. |
|
Display rectangles with x, y values mapped to the center of the tile. |
|
Display error bars defined by the upper and lower values. |
|
Display bars with horizontal median line. |
|
Display a line range defined by an upper and lower value. |
|
Add a vertical line defined by upper and lower value with midpoint at y location. |
|
Display contours of a 3d surface in 2d. |
|
Fill contours of a 3d surface in 2d. |
|
Display a filled closed path defined by the vertex coordinates of individual polygons. |
|
Display polygons from a reference map. |
|
Add a straight line with specified slope and intercept to the plot. |
|
Add a straight horizontal line to the plot. |
|
Add a straight vertical line to the plot. |
|
Add a straight vertical or horizontal band to the plot. |
|
Display the distribution of data based on a five number summary ("minimum", first quartile (Q1), median, third quartile (Q3), and "maximum"), and "outlying" points individually. |
|
A violin plot is a mirrored density plot with an additional grouping as for a boxplot. |
|
Plot the sum of the y and height aesthetics versus x. |
|
Dotplot represents individual observations in a batch of data with circular dots. |
|
Display a y interval defined by ymin and ymax. |
|
Display the development of quantitative values over an interval. |
|
Display kernel density estimate, which is a smoothed version of the histogram. |
|
Display density function contour. |
|
Fill density function contour. |
|
Display jittered points, especially for discrete plots or dense plots. |
|
Display a line chart which makes the y value proportional to the number of observed variable values, mapped to x axis. |
|
Connect observations in the order in which they appear in the data by stairs. |
|
Display an axis-aligned rectangle defined by two corners. |
|
Draw a straight line segment between two points. |
|
Draw a curved line. |
|
Draw a straight line segment with given length and angle from the starting point. |
|
Add a text directly to the plot. |
|
Add a text directly to the plot with a rectangle behind the text. |
|
Display quantile-quantile plot. |
|
Display quantile-quantile plot. |
|
Display quantile-quantile fitting line. |
|
Display quantile-quantile fitting line. |
|
Compute and draw a function. |
|
Draw nothing, but can be a useful way of ensuring common scales between different plots (see expand_limits()). |
Additional Geometries#
Display image specified by ndarray with shape. |
|
Display an interactive map. |
Stats#
Sum unique values. |
|
Display the aggregated values of a single continuous variable grouped along the x axis. |
|
Display a distribution by dividing variable mapped to x axis into bins and applying aggregation functions to each bin. |
|
Display the empirical cumulative distribution function. |
Extras#
Describe arrows to add to a line. |
|
Expand the plot limits to include additional data values. |
The function converts a column to a discrete scale and allows you to specify the order of its values. |
Configure annotations (for pie and bar charts). |
Facets#
Split data by one or two faceting variables. |
|
Split data by one or more faceting variables. |
Scales#
Position Scales#
Discrete position scale x. |
|
Discrete position scale y. |
|
Reversed discrete position scale x. |
|
Reversed discrete position scale y. |
|
Continuous position scale x. |
|
Continuous position scale y. |
|
Continuous position scale x where trans='log10'. |
|
Continuous position scales y where trans='log10'. |
|
Continuous position scale x where trans='log2'. |
|
Continuous position scales y where trans='log2'. |
|
Continuous position scale x where trans='reverse'. |
|
Continuous position scale y where trans='reverse'. |
Color Scales#
Create your own discrete scale for color aesthetic. |
|
Define smooth color gradient between two colors for color aesthetic. |
|
Color scale for color aesthetic and continuous data. |
|
Define diverging color gradient for color aesthetic. |
|
Define smooth color gradient between multiple colors for color aesthetic. |
|
Qualitative color scale with evenly spaced hues for color aesthetic. |
|
Color scale for color aesthetic and discrete data. |
|
Sequential grey color scale for color aesthetic. |
|
Sequential, diverging and qualitative color scales from colorbrewer2.org for color aesthetic. |
|
The viridis color maps are designed to be perceptually-uniform, both in regular form and also when converted to black-and-white. |
|
Create a scale for the 'color' aesthetic using matplotlib colormap. |
Fill Scales#
Create your own discrete scale for fill aesthetic. |
|
Define smooth color gradient between two colors for fill aesthetic. |
|
Color scale for fill aesthetic and continuous data. |
|
Define diverging color gradient for fill aesthetic. |
|
Define smooth color gradient between multiple colors for fill aesthetic. |
|
Qualitative color scale with evenly spaced hues for fill aesthetic. |
|
Color scale for fill aesthetic and discrete data. |
|
Sequential grey color scale for fill aesthetic. |
|
Sequential, diverging and qualitative color scales from colorbrewer2.org for fill aesthetic. |
|
The viridis color maps are designed to be perceptually-uniform, both in regular form and also when converted to black-and-white. |
|
Create a scale for the 'fill' aesthetic using matplotlib colormap. |
Flexible Color Scales#
Create your own discrete scale for the specified aesthetics. |
|
Define smooth color gradient between two colors for the specified aesthetics. |
|
General purpose scale for continuous data. |
|
Define diverging color gradient for the specified aesthetics. |
|
Define smooth color gradient between multiple colors for the specified aesthetics. |
|
Qualitative color scale with evenly spaced hues for the specified aesthetics. |
|
General purpose scale for discrete data. |
|
Sequential grey color scale for the specified aesthetics. |
|
Sequential, diverging and qualitative color scales from colorbrewer2.org for the specified aesthetics. |
|
The viridis color maps are designed to be perceptually-uniform, both in regular form and also when converted to black-and-white. |
|
Create a scale for color-related aesthetic using matplotlib colormap. |
Shape Scales#
Scale for shapes. |
|
Create your own discrete scale for shape aesthetic. |
Size Scales#
Create your own discrete scale for size aesthetic. |
|
Scale for size. |
|
Continuous scale for size that maps 0 to 0. |
|
Scale for linewidth. |
|
Scale for stroke. |
Alpha Scales#
Create your own discrete scale for alpha (transparency) aesthetic. |
|
Scale for alpha. |
Linetype Scales#
Create your own discrete scale for line type aesthetic. |
Datetime Scales#
Position scale x for date/time data. |
|
Position scale y for date/time data. |
|
Position scale x for data representing "time delta" values expressed in milliseconds. |
|
Position scale y for data representing "time delta" values expressed in milliseconds. |
Identity Scales#
Use this scale when your data has already been scaled. |
|
Use this scale when your data has already been scaled. |
|
Use this scale when your data has already been scaled. |
|
Use this scale when your data has already been scaled. |
|
Use this scale when your data has already been scaled. |
|
Use this scale when your data has already been scaled. |
|
Use this scale when your data has already been scaled. |
|
Use this scale when your data has already been scaled. |
|
Use this scale when your data has already been scaled. |
Scale Limits#
Scale Guides#
Legend guide. |
|
Continuous color bar guide. |
|
Set guides for each scale. |
|
Configure custom legend. |
Positions#
Adjust position by dodging overlaps to the side. |
|
Adjust position by dodging overlaps to the side. |
|
Adjust position by assigning random noise to points. |
|
Adjust position by nudging a given offset. |
|
This is primarily used for aligning points generated through geom_point() with dodged boxplots (e.g., a geom_boxplot() with a fill aesthetic supplied). |
|
Adjust position by stacking overlapping objects on top of each other and standardise each stack to have constant height. |
|
Adjust position by stacking overlapping objects on top of each other. |
Coordinate Systems#
The Cartesian coordinate system is the most familiar and common type of coordinate system. |
|
A fixed scale coordinate system forces a specified ratio between the physical representations of data units on the axes. |
|
Polar coordinate system. |
|
Project a portion of the earth, which is approximately spherical, onto a flat 2D plane. |
|
Flip axis of default coordinate system so that horizontal axis becomes vertical and vice versa. |
Theme#
Base#
Use theme() to modify individual components of a theme, allowing you to control all non-data components of the plot. |
|
Specify how non-data components of the plot are drawn. |
|
Specify how non-data components of the plot are drawn. |
|
Specify how non-data components of the plot are drawn. |
|
Specify how non-data components of the plot are drawn. |
|
Specify new values for the named colors. |
|
Function margin() is deprecated. |
|
Specify overall size of plot. |
Predefined Themes#
Basic settings are applied. |
|
A completely blank (or "void") background theme: no borders, axes, or gridlines. |
|
Grey lines on white background with dark grey plot border. |
|
Dark grey axes and no gridlines. |
|
Grey background and white gridlines. |
|
Light grey lines of various widths on white background. |
|
A minimalistic theme without axes lines. |
|
Default theme similar to theme_minimal() but with x axis line and only major grid lines. |
Flavors#
Darcula color scheme. |
|
High contrast dark color scheme. |
|
High contrast light color scheme. |
|
Solarized dark color scheme. |
|
Solarized light color scheme. |
Labels#
Tooltips#
Configure tooltips. |
Font Features#
Adjust estimated width of text labels on plot. |
|
Specify properties of a particular font-family to adjust estimated width of text labels on plot. |
Sampling#
Return a subset of randomly selected items. |
|
Randomly sample from each stratum (subgroup). |
|
'Pick' sampling. |
|
Return a subset where items are selected at a regular interval. |
|
Return a subset of randomly selected groups. |
|
Return a subset where groups are selected at a regular interval. |
|
Simplify a polyline using the Visvalingam-Whyatt algorithm. |
|
Simplify a polyline using the Douglas-Peucker algorithm. |
Bistro Module#
Display a set of images in a grid. |
This class is intended to build correlation matrix plot. |
Produce a Q-Q plot (quantile-quantile plot). |
Produce a joint plot that contains bivariate and univariate graphs at the same time. |
Produce a residual plot that shows the difference between the observed response and the fitted response values. |
A waterfall plot shows the cumulative effect of sequentially introduced positive or negative values. |
Geospatial#
Do not use this class explicitly. |
|
Create a NamesGeocoder. |
|
Create a NamesGeocoder object for cities. |
|
Create a NamesGeocoder object for counties. |
|
Create a NamesGeocoder object for states. |
|
Create a NamesGeocoder object for countries. |
|
Calculate the distance between two points. |
Make raster tiles config. |
|
Make vector tiles config. |
|
Make solid color tiles config. |
Default vector tiles. |
|
Vector tiles, light theme. |
|
Vector tiles, dark theme. |
|
Vector tiles, BW theme. |
|
Blank tiles. |
|
OpenStreetMap's standard tile layer. |
|
OpenTopoMap's tile layer. |
|
CARTO tiles, positron theme. |
|
CARTO tiles, positron theme. |
|
CARTO tiles, positron (no labels) theme. |
|
CARTO tiles, positron (no labels) theme. |
|
CARTO tiles, dark matter (no labels) theme. |
|
CARTO tiles, dark matter (no labels) theme. |
|
CARTO tiles, voyager theme. |
|
CARTO tiles, voyager theme. |
|
NASA tiles, CityLights 2012 theme. |
|
NASA tiles, greyscale shaded relief (30m) theme. |
|
NASA tiles, color shaded relief (30m) theme. |
|
NASA tiles, Terra TrueColor theme. |