API Reference#

Configuring#

LetsPlot

Initialize the library and its options.

Plotting#

PlotSpec

A class of the initial plot object.

ggplot

Create a new ggplot plot.

GGBunch

Collection of plots created by ggplot function.

gggrid

Combine several plots on one figure, organized in a regular grid.

ggmarginal

Convert a given geometry layer to a marginal layer.

aes

Define aesthetic mappings.

ggsave

Export plot or bunch to a file.

Geometries#

Standard Geometries#

geom_point

Draw points defined by an x and y coordinate, as for a scatter plot.

geom_path

Connect observations in the order, how they appear in the data.

geom_line

Connect points in the order of the variable on the x axis.

geom_smooth

Add a smoothed conditional mean.

geom_bar

Display a bar chart which makes the height of the bar proportional to the number of observed variable values, mapped to x axis.

geom_count

Sum unique values.

geom_pie

Draw pie chart.

geom_lollipop

Draw lollipop chart.

geom_histogram

Display a 1d distribution by dividing variable mapped to x axis into bins and counting the number of observations in each bin.

geom_dotplot

Dotplot represents individual observations in a batch of data with circular dots.

geom_bin2d

Divides the plane into a grid and color the bins by the count of cases in them.

geom_tile

Display rectangles with x, y values mapped to the center of the tile.

geom_raster

Display rectangles with x, y values mapped to the center of the tile.

geom_errorbar

Display error bars defined by the upper and lower values.

geom_crossbar

Display bars with horizontal median line.

geom_linerange

Display a line range defined by an upper and lower value.

geom_pointrange

Add a vertical line defined by upper and lower value with midpoint at y location.

geom_contour

Display contours of a 3d surface in 2d.

geom_contourf

Fill contours of a 3d surface in 2d.

geom_polygon

Display a filled closed path defined by the vertex coordinates of individual polygons.

geom_map

Display polygons from a reference map.

geom_abline

Add a straight line with specified slope and intercept to the plot.

geom_hline

Add a straight horizontal line to the plot.

geom_vline

Add a straight vertical line to the plot.

geom_boxplot

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.

geom_violin

A violin plot is a mirrored density plot with an additional grouping as for a boxplot.

geom_area_ridges

Plot the sum of the y and height aesthetics versus x.

geom_ydotplot

Dotplot represents individual observations in a batch of data with circular dots.

geom_ribbon

Display a y interval defined by ymin and ymax.

geom_area

Display the development of quantitative values over an interval.

geom_density

Display kernel density estimate, which is a smoothed version of the histogram.

geom_density2d

Display density function contour.

geom_density2df

Fill density function contour.

geom_jitter

Display jittered points, especially for discrete plots or dense plots.

geom_freqpoly

Display a line chart which makes the y value proportional to the number of observed variable values, mapped to x axis.

geom_step

Connect observations in the order in which they appear in the data by stairs.

geom_rect

Display an axis-aligned rectangle defined by two corners.

geom_segment

Draw a straight line segment between two points.

geom_curve

Draw a curved line.

geom_spoke

Draw a straight line segment with given length and angle from the starting point.

geom_text

Add a text directly to the plot.

geom_label

Add a text directly to the plot with a rectangle behind the text.

geom_qq

Display quantile-quantile plot.

geom_qq2

Display quantile-quantile plot.

geom_qq_line

Display quantile-quantile fitting line.

geom_qq2_line

Display quantile-quantile fitting line.

geom_function

Compute and draw a function.

Additional Geometries#

geom_imshow

Display image specified by ndarray with shape.

geom_livemap

Display an interactive map.

Stats#

stat_sum

Sum unique values.

stat_summary

Display the aggregated values of a single continuous variable grouped along the x axis.

stat_summary_bin

Display a distribution by dividing variable mapped to x axis into bins and applying aggregation functions to each bin.

stat_ecdf

Display the empirical cumulative distribution function.

Extras#

arrow

Describe arrows to add to a line.

as_discrete

The function is used to annotate a numeric data series as categorical data with the possibility of its ordering for the purposes of given visualization.

layer_labels

Configure annotations (for pie and bar charts).

Facets#

facet_grid

Split data by one or two faceting variables.

facet_wrap

Split data by one or more faceting variables.

Scales#

Position Scales#

scale_x_discrete

Discrete position scale x.

scale_y_discrete

Discrete position scale y.

scale_x_discrete_reversed

Reversed discrete position scale x.

scale_y_discrete_reversed

Reversed discrete position scale y.

scale_x_continuous

Continuous position scale x.

scale_y_continuous

Continuous position scale y.

scale_x_log10

Continuous position scale x where trans='log10'.

scale_y_log10

Continuous position scales y where trans='log10'.

scale_x_log2

Continuous position scale x where trans='log2'.

scale_y_log2

Continuous position scales y where trans='log2'.

scale_x_reverse

Continuous position scale x where trans='reverse'.

scale_y_reverse

Continuous position scale y where trans='reverse'.

Color Scales#

scale_color_manual

Create your own discrete scale for color aesthetic.

scale_color_gradient

Define smooth color gradient between two colors for color aesthetic.

scale_color_continuous

Color scale for color aesthetic and continuous data.

scale_color_gradient2

Define diverging color gradient for color aesthetic.

scale_color_gradientn

Define smooth color gradient between multiple colors for color aesthetic.

scale_color_hue

Qualitative color scale with evenly spaced hues for color aesthetic.

scale_color_discrete

Color scale for color aesthetic and discrete data.

scale_color_grey

Sequential grey color scale for color aesthetic.

scale_color_brewer

Sequential, diverging and qualitative color scales from colorbrewer2.org for color aesthetic.

scale_color_viridis

The viridis color maps are designed to be perceptually-uniform, both in regular form and also when converted to black-and-white.

Fill Scales#

scale_fill_manual

Create your own discrete scale for fill aesthetic.

scale_fill_gradient

Define smooth color gradient between two colors for fill aesthetic.

scale_fill_continuous

Color scale for fill aesthetic and continuous data.

scale_fill_gradient2

Define diverging color gradient for fill aesthetic.

scale_fill_gradientn

Define smooth color gradient between multiple colors for fill aesthetic.

scale_fill_hue

Qualitative color scale with evenly spaced hues for fill aesthetic.

scale_fill_discrete

Color scale for fill aesthetic and discrete data.

scale_fill_grey

Sequential grey color scale for fill aesthetic.

scale_fill_brewer

Sequential, diverging and qualitative color scales from colorbrewer2.org for fill aesthetic.

scale_fill_viridis

The viridis color maps are designed to be perceptually-uniform, both in regular form and also when converted to black-and-white.

Flexible Color Scales#

scale_manual

Create your own discrete scale for the specified aesthetics.

scale_gradient

Define smooth color gradient between two colors for the specified aesthetics.

scale_continuous

General purpose scale for continuous data.

scale_gradient2

Define diverging color gradient for the specified aesthetics.

scale_gradientn

Define smooth color gradient between multiple colors for the specified aesthetics.

scale_hue

Qualitative color scale with evenly spaced hues for the specified aesthetics.

scale_discrete

General purpose scale for discrete data.

scale_grey

Sequential grey color scale for the specified aesthetics.

scale_brewer

Sequential, diverging and qualitative color scales from colorbrewer2.org for the specified aesthetics.

scale_viridis

The viridis color maps are designed to be perceptually-uniform, both in regular form and also when converted to black-and-white.

Shape Scales#

scale_shape

Scale for shapes.

scale_shape_manual

Create your own discrete scale for shape aesthetic.

Size Scales#

scale_size_manual

Create your own discrete scale for size aesthetic.

scale_size

Scale for size.

scale_size_area

Continuous scale for size that maps 0 to 0.

scale_linewidth

Scale for linewidth.

scale_stroke

Scale for stroke.

Alpha Scales#

scale_alpha_manual

Create your own discrete scale for alpha (transparency) aesthetic.

scale_alpha

Scale for alpha.

Linetype Scales#

scale_linetype_manual

Create your own discrete scale for line type aesthetic.

Datetime Scales#

scale_x_datetime

Position scale x for date/time data.

scale_y_datetime

Position scale y for date/time data.

scale_x_time

Position scale x for data representing "time delta" values expressed in milliseconds.

scale_y_time

Position scale y for data representing "time delta" values expressed in milliseconds.

Identity Scales#

scale_identity

Use this scale when your data has already been scaled.

scale_color_identity

Use this scale when your data has already been scaled.

scale_fill_identity

Use this scale when your data has already been scaled.

scale_shape_identity

Use this scale when your data has already been scaled.

scale_linetype_identity

Use this scale when your data has already been scaled.

scale_alpha_identity

Use this scale when your data has already been scaled.

scale_size_identity

Use this scale when your data has already been scaled.

scale_linewidth_identity

Use this scale when your data has already been scaled.

scale_stroke_identity

Use this scale when your data has already been scaled.

Scale Limits#

lims

This is a shortcut for supplying the limits parameter to the x and y axes.

xlim

This is a shortcut for supplying the limits parameter to the x axis.

ylim

This is a shortcut for supplying the limits parameter to the y axis.

Scale Guides#

guide_legend

Legend guide.

guide_colorbar

Continuous color bar guide.

guides

Set guides for each scale.

Positions#

position_dodge

Adjust position by dodging overlaps to the side.

position_dodgev

Adjust position by dodging overlaps to the side.

position_jitter

Adjust position by assigning random noise to points.

position_nudge

Adjust position by nudging a given offset.

position_jitterdodge

This is primarily used for aligning points generated through geom_point() with dodged boxplots (e.g., a geom_boxplot() with a fill aesthetic supplied).

position_fill

Adjust position by stacking overlapping objects on top of each other and standardise each stack to have constant height.

position_stack

Adjust position by stacking overlapping objects on top of each other.

Coordinate Systems#

coord_cartesian

The Cartesian coordinate system is the most familiar and common type of coordinate system.

coord_fixed

A fixed scale coordinate system forces a specified ratio between the physical representations of data units on the axes.

coord_polar

Polar coordinate system.

coord_map

Project a portion of the earth, which is approximately spherical, onto a flat 2D plane.

coord_flip

Flip axis of default coordinate system so that horizontal axis becomes vertical and vice versa.

Theme#

Base#

theme

Use theme() to modify individual components of a theme, allowing you to control all non-data components of the plot.

element_blank

Specify how non-data components of the plot are drawn.

element_rect

Specify how non-data components of the plot are drawn.

element_line

Specify how non-data components of the plot are drawn.

element_text

Specify how non-data components of the plot are drawn.

element_geom

Specify new values for the named colors.

margin

Function margin() is deprecated.

ggsize

Specify overall size of plot.

Predefined Themes#

theme_none

Basic settings are applied.

theme_void

A completely blank (or "void") background theme: no borders, axes, or gridlines.

theme_bw

Grey lines on white background with dark grey plot border.

theme_classic

Dark grey axes and no gridlines.

theme_grey

Grey background and white gridlines.

theme_light

Light grey lines of various widths on white background.

theme_minimal

A minimalistic theme without axes lines.

theme_minimal2

Default theme similar to theme_minimal() but with x axis line and only major grid lines.

Flavors#

flavor_darcula

Darcula color scheme.

flavor_high_contrast_dark

High contrast dark color scheme.

flavor_high_contrast_light

High contrast light color scheme.

flavor_solarized_dark

Solarized dark color scheme.

flavor_solarized_light

Solarized light color scheme.

Labels#

ggtitle

Add title to the plot.

labs

Change plot title and axis label.

xlab

Add label to the x axis.

ylab

Add label to the y axis.

Tooltips#

layer_tooltips

Configure tooltips.

Font Features#

font_metrics_adjustment

Adjust estimated width of text labels on plot.

font_family_info

Specify properties of a particular font-family to adjust estimated width of text labels on plot.

Sampling#

sampling_random

Return a subset of randomly selected items.

sampling_random_stratified

Randomly sample from each stratum (subgroup).

sampling_pick

'Pick' sampling.

sampling_systematic

Return a subset where items are selected at a regular interval.

sampling_group_random

Return a subset of randomly selected groups.

sampling_group_systematic

Return a subset where groups are selected at a regular interval.

sampling_vertex_vw

Simplify a polyline using the Visvalingam-Whyatt algorithm.

sampling_vertex_dp

Simplify a polyline using the Douglas-Peucker algorithm.

Bistro Module#

image_matrix

Display a set of images in a grid.

corr_plot

This class is intended to build correlation matrix plot.

qq_plot

Produce a Q-Q plot (quantile-quantile plot).

joint_plot

Produce a joint plot that contains bivariate and univariate graphs at the same time.

residual_plot

Produce a residual plot that shows the difference between the observed response and the fitted response values.

Geospatial#

NamesGeocoder

Do not use this class explicitly.

geocode

Create a NamesGeocoder.

geocode_cities

Create a NamesGeocoder object for cities.

geocode_counties

Create a NamesGeocoder object for counties.

geocode_states

Create a NamesGeocoder object for states.

geocode_countries

Create a NamesGeocoder object for countries.

distance

Calculate the distance between two points.

maptiles_zxy

Make raster tiles config.

maptiles_lets_plot

Make vector tiles config.

maptiles_solid

Make solid color tiles config.

LETS_PLOT_COLOR

Default vector tiles.

LETS_PLOT_LIGHT

Vector tiles, light theme.

LETS_PLOT_DARK

Vector tiles, dark theme.

LETS_PLOT_BW

Vector tiles, BW theme.

SOLID

Blank tiles.

OSM

OpenStreetMap's standard tile layer.

OPEN_TOPO_MAP

OpenTopoMap's tile layer.

CARTO_POSITRON

CARTO tiles, positron theme.

CARTO_POSITRON_HIRES

CARTO tiles, positron theme.

CARTO_POSITRON_NO_LABELS

CARTO tiles, positron (no labels) theme.

CARTO_POSITRON_NO_LABELS_HIRES

CARTO tiles, positron (no labels) theme.

CARTO_DARK_MATTER_NO_LABELS

CARTO tiles, dark matter (no labels) theme.

CARTO_DARK_MATTER_NO_LABELS_HIRES

CARTO tiles, dark matter (no labels) theme.

CARTO_VOYAGER

CARTO tiles, voyager theme.

CARTO_VOYAGER_HIRES

CARTO tiles, voyager theme.

CARTO_MIDNIGHT_COMMANDER

CARTO tiles, midnight commander theme.

CARTO_MIDNIGHT_COMMANDER_HIRES

CARTO tiles, midnight commander theme.

CARTO_ANTIQUE

CARTO tiles, antique theme.

CARTO_ANTIQUE_HIRES

CARTO tiles, antique theme.

CARTO_FLAT_BLUE

CARTO tiles, flat blue theme.

CARTO_FLAT_BLUE_HIRES

CARTO tiles, flat blue theme.

NASA_CITYLIGHTS_2012

NASA tiles, CityLights 2012 theme.

NASA_GREYSCALE_SHADED_RELIEF_30M

NASA tiles, greyscale shaded relief (30m) theme.

NASA_COLOR_SHADED_RELIEF_30M

NASA tiles, color shaded relief (30m) theme.

NASA_TERRA_TRUECOLOR

NASA tiles, Terra TrueColor theme.