Learn R Programming

⚠️There's a newer version (3.5.0) of this package.Take me there.

ggplot2

ggplot2 is a plotting system for R, based on the grammar of graphics, which tries to take the good parts of base and lattice graphics and avoid bad parts. It takes care of many of the fiddly details that make plotting a hassle (like drawing legends) as well as providing a powerful model of graphics that makes it easy to produce complex multi-layered graphics.

Find out more at http://ggplot2.org, and check out the nearly 500 examples of ggplot in use. If you're interested, you can also sign up to the ggplot2 mailing list at.

Installation

Get the released version from CRAN:

install.packages("ggplot2")

Or the development version from github:

# install.packages("devtools")
devtools::install_github("hadley/ggplot2")

Copy Link

Version

Install

install.packages('ggplot2')

Monthly Downloads

1,654,148

Version

2.1.0

License

GPL-2

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

March 1st, 2016

Functions in ggplot2 (2.1.0)

coord_munch

Munch coordinates data
cut_interval

Cut up numeric vector into useful groups.
aes

Define aesthetic mappings.
coord_fixed

Cartesian coordinates with fixed relationship between x and y scales.
annotation_logticks

Annotation: log tick marks
draw_key

Key drawing functions
mean_se

Calculate mean and standard errors on either side.
coord_map

Map projections.
geom_errorbarh

Horizontal error bars
geom_bar

Bars, rectangles with bases on x-axis
is.theme

Reports whether x is a theme object
annotate

Create an annotation layer.
annotation_custom

Annotation: Custom grob.
geom_violin

Violin plot.
scale_colour_brewer

Sequential, diverging and qualitative colour scales from colorbrewer.org
scale_colour_grey

Sequential grey colour scale.
guides

Set guides for each scale.
aes_colour_fill_alpha

Colour related aesthetics: colour, fill and alpha
coord_polar

Polar coordinates.
is.ggplot

Reports whether x is a ggplot object
ggtheme

ggplot2 themes
geom_crossbar

Vertical intervals: lines, crossbars & errorbars.
absoluteGrob

Absolute grob
geom_label

Textual annotations.
ggplot_build

Build ggplot for rendering.
scale_size

Scale size (area or radius).
geom_quantile

Add quantile lines from a quantile regression.
ggplot2-ggproto

Base ggproto classes for ggplot2
geom_bin2d

Add heatmap of 2d bin counts.
zeroGrob

The zero grob draws nothing and has zero size.
mpg

Fuel economy data from 1999 and 2008 for 38 popular models of car
stat_identity

Identity statistic.
geom_density_2d

Contours from a 2d density estimate.
economics

US economic time series.
geom_spoke

A line segment parameterised by location, direction and distance.
theme_update

Get, set and update themes.
scale_x_discrete

Discrete position.
update_geom_defaults

Modify geom/stat aesthetic defaults for future plots
scale_colour_hue

Qualitative colour scale with evenly spaced hues.
benchplot

Benchmark plot creation time. Broken down into construct, build, render and draw times.
element_grob

Generate grid grob from theme element
geom_freqpoly

Histograms and frequency polygons.
aes_

Define aesthetic mappings from strings, or quoted calls and formulas.
luv_colours

colors() in Luv space.
aes_position

Position related aesthetics: x, y, xmin, xmax, ymin, ymax, xend, yend
hmisc

is.rel

Reports whether x is a rel object
aes_all

Given a character vector, create a set of identity mappings
ggplot

Create a new ggplot plot.
autoplot

Create a complete ggplot appropriate to a particular data type
lims

Convenience functions to set the axis limits.
margin

Define margins.
ggsave

Save a ggplot (or other grid object) with sensible defaults
facet

Facet specification.
geom_raster

Draw rectangles.
labs

Change axis labels and legend titles
geom_boxplot

Box and whiskers plot.
is.Coord

Is this object a coordinate system?
annotation_map

Annotation: maps.
position_jitter

Jitter points to avoid overplotting.
scale_colour_gradient

Smooth gradient between two colours
geom_segment

Line segments and curves.
labeller

Generic labeller function for facets
position_nudge

Nudge points.
as.list.ggproto

Convert a ggproto object to a list
is.facet

Is this object a facetting specification?
add_theme

Modify properties of an element in a theme object
layer

Create a new layer
stat_unique

Remove duplicates.
annotation_raster

Annotation: High-performance rectangular tiling.
facet_null

Facet specification: a single panel.
geom_contour

Display contours of a 3d surface in 2d.
element_text

Theme element: text.
geom_polygon

Polygon, a filled path.
geom_smooth

Add a smoothed conditional mean.
coord_trans

Transformed cartesian coordinate system.
geom_path

Connect observations.
calc_element

Calculate the element properties, by inheriting properties from its parents
scale_manual

Create your own discrete scale.
geom_blank

Blank, draws nothing.
geom_density

Display a smooth density estimate.
map_data

Create a data frame of map data.
fortify-multcomp

Fortify methods for objects produced by multcomp
position_fill

Stack overlapping objects on top of one another.
discrete_scale

Discrete scale constructor.
stat_ellipse

Plot data ellipses.
fortify.sp

Fortify method for classes from the sp package.
position_dodge

Adjust position by dodging overlaps to the side.
msleep

An updated and expanded version of the mammals sleep dataset.
geom_dotplot

Dot plot
element_rect

Theme element: rectangle.
presidential

Terms of 11 presidents from Eisenhower to Obama.
stat_qq

Calculation for quantile-quantile plot.
coord_cartesian

Cartesian coordinates.
stat_summary_bin

Summarise y values at unique/binned x x.
coord_flip

Flipped cartesian coordinates.
gg_dep

Give a deprecation error, warning, or message, depending on version number.
scale_alpha

Alpha scales.
element_line

Theme element: line.
geom_point

Points, as for a scatterplot
scale_date

Position scale, date & date times
remove_missing

Convenience function to remove missing values from a data.frame
stat_function

Superimpose a function.
theme

Set theme elements
facet_grid

Lay out panels in a grid.
facet_wrap

Wrap a 1d ribbon of panels into 2d.
rel

Relative sizing for theme elements
is.ggproto

Is an object a ggproto object?
geom_rug

Marginal rug plots.
expand_limits

Expand the plot limits with data.
update_labels

Update axis/legend labels
translate_qplot_ggplot

Translating between qplot and ggplot
fortify.map

Fortify method for map objects.
fortify.lm

Supplement the data fitted to a linear model with model fit statistics.
geom_jitter

Points, jittered to reduce overplotting.
+.gg

Add a new component to a ggplot or theme object.
scale_identity

Use values without scaling.
print.ggproto

Print a ggproto object
aes_group_order

Aesthetics: group
scale_linetype

Scale for line patterns.
label_bquote

Backquoted labeller
borders

Create a layer of map borders.
aes_auto

Automatic aesthetic mapping
labellers

Labeller functions
position_identity

Don't adjust position
geom_hex

Hexagon binning.
qplot

Quick plot
geom_abline

Lines: horizontal, vertical, and specified by slope and intercept.
last_plot

Retrieve the last plot to be modified or created.
midwest

Midwest demographics.
ggplotGrob

Generate a ggplot2 plot grob.
element_blank

Theme element: blank. This theme element draws nothing, and assigns no space
ggplot_gtable

Build a plot with all the usual bits and pieces.
txhousing

Housing sales in TX.
should_stop

Used in examples to illustrate when errors should occur.
stat_summary_2d

Bin and summarise in 2d (rectangle & hexagons)
ggproto

Create a new ggproto object
print.ggplot

Draw plot on current graphics device.
diamonds

Prices of 50,000 round cut diamonds
position_jitterdodge

Adjust position by simultaneously dodging and jittering
geom_map

Polygons from a reference map.
limits

Generate correct scale type for specified limits
scale_continuous

Continuous position scales (x & y).
summary.ggplot

Displays a useful description of a ggplot object
translate_qplot_lattice

Translating between qplot and lattice
seals

Vector field of seal movements.
waiver

A waiver object.
resolution

Compute the "resolution" of a data vector.
as_labeller

Coerce to labeller function
continuous_scale

Continuous scale constructor.
aes_linetype_size_shape

Differentiation related aesthetics: linetype, size, shape
fortify

Fortify a model with data.
geom_ribbon

Ribbons and area plots.
guide_colourbar

Continuous colour bar guide.
format.ggproto

Format a ggproto object
faithfuld

2d density estimate of Old Faithful data
geom_count

Count the number of observations at each location.
graphical-units

Graphical units
guide_legend

Legend guide.
stat_ecdf

Empirical Cumulative Density Function
reexports

Objects exported from other packages
scale_shape

Scale for shapes, aka glyphs.
transform_position

Convenience function to transform all position variables.