ggplot2 2.1.0

by Hadley Wickham
Other versions:

Monthly downloads




An Implementation of the Grammar of Graphics

An implementation of the grammar of graphics in R. It combines the advantages of both base and lattice graphics: conditioning and shared axes are handled automatically, and you can still build up a plot step by step from multiple data sources. It also implements a sophisticated multidimensional conditioning system and a consistent interface to map data to aesthetic attributes. See for more information, documentation and examples.



Build Status CRAN_Status_Badge

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, 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.


Get the released version from CRAN:


Or the development version from github:

# install.packages("devtools")

Functions in ggplot2

Name Description
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
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 Wrap up a selection of summary functions from Hmisc to make it easy to use with stat_summary.
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 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. 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.
No Results!

Last month downloads


License GPL-2
LazyData true
Collate 'ggproto.r' 'aaa-.r' 'aes-calculated.r' 'aes-colour-fill-alpha.r' 'aes-group-order.r' 'aes-linetype-size-shape.r' 'aes-position.r' 'utilities.r' 'aes.r' 'legend-draw.r' 'geom-.r' 'annotation-custom.r' 'annotation-logticks.r' 'geom-polygon.r' 'geom-map.r' 'annotation-map.r' 'geom-raster.r' 'annotation-raster.r' 'annotation.r' 'autoplot.r' 'bench.r' 'bin.R' 'coord-.r' 'coord-cartesian-.r' 'coord-fixed.r' 'coord-flip.r' 'coord-map.r' 'coord-munch.r' 'coord-polar.r' 'coord-quickmap.R' 'coord-transform.r' 'data.R' 'facet-.r' 'facet-grid-.r' 'facet-labels.r' 'facet-layout.r' 'facet-locate.r' 'facet-null.r' 'facet-viewports.r' 'facet-wrap.r' 'fortify-lm.r' 'fortify-map.r' 'fortify-multcomp.r' 'fortify-spatial.r' 'fortify.r' 'stat-.r' 'geom-abline.r' 'geom-rect.r' 'geom-bar.r' 'geom-bin2d.r' 'geom-blank.r' 'geom-boxplot.r' 'geom-path.r' 'geom-contour.r' 'geom-count.r' 'geom-crossbar.r' 'geom-segment.r' 'geom-curve.r' 'geom-defaults.r' 'geom-ribbon.r' 'geom-density.r' 'geom-density2d.r' 'geom-dotplot.r' 'geom-errorbar.r' 'geom-errorbarh.r' 'geom-freqpoly.r' 'geom-hex.r' 'geom-histogram.r' 'geom-hline.r' 'geom-jitter.r' 'geom-label.R' 'geom-linerange.r' 'geom-point.r' 'geom-pointrange.r' 'geom-quantile.r' 'geom-rug.r' 'geom-smooth.r' 'geom-spoke.r' 'geom-text.r' 'geom-tile.r' 'geom-violin.r' 'geom-vline.r' 'ggplot2.r' 'grob-absolute.r' 'grob-dotstack.r' 'grob-null.r' 'grouping.r' 'guide-colorbar.r' 'guide-legend.r' 'guides-.r' 'guides-axis.r' 'guides-grid.r' 'hexbin.R' 'labels.r' 'layer.r' 'limits.r' 'margins.R' 'panel.r' 'plot-build.r' 'plot-construction.r' 'plot-last.r' 'plot.r' 'position-.r' 'position-collide.r' 'position-dodge.r' 'position-fill.r' 'position-identity.r' 'position-jitter.r' 'position-jitterdodge.R' 'position-nudge.R' 'position-stack.r' 'quick-plot.r' 'range.r' 'save.r' 'scale-.r' 'scale-alpha.r' 'scale-brewer.r' 'scale-continuous.r' 'scale-date.r' 'scale-discrete-.r' 'scale-gradient.r' 'scale-grey.r' 'scale-hue.r' 'scale-identity.r' 'scale-linetype.r' 'scale-manual.r' 'scale-shape.r' 'scale-size.r' 'scale-type.R' 'scales-.r' 'stat-bin.r' 'stat-bin2d.r' 'stat-bindot.r' 'stat-binhex.r' 'stat-boxplot.r' 'stat-contour.r' 'stat-count.r' 'stat-density-2d.r' 'stat-density.r' 'stat-ecdf.r' 'stat-ellipse.R' 'stat-function.r' 'stat-identity.r' 'stat-qq.r' 'stat-quantile.r' 'stat-smooth-methods.r' 'stat-smooth.r' 'stat-sum.r' 'stat-summary-2d.r' 'stat-summary-bin.R' 'stat-summary-hex.r' 'stat-summary.r' 'stat-unique.r' 'stat-ydensity.r' 'summary.r' 'theme-defaults.r' 'theme-elements.r' 'theme.r' 'translate-qplot-ggplot.r' 'translate-qplot-lattice.r' 'utilities-break.r' 'utilities-grid.r' 'utilities-help.r' 'utilities-matrix.r' 'utilities-resolution.r' 'utilities-table.r' 'zxx.r' 'zzz.r'
VignetteBuilder knitr
RoxygenNote 5.0.1
NeedsCompilation no
Packaged 2016-02-29 20:47:22 UTC; hadley
Repository CRAN
Date/Publication 2016-03-01 15:47:24

Include our badge in your README