ggplot2: Create Elegant Data Visualisations Using the Grammar of Graphics (original) (raw)

Add components to a plot

%+% +.gg

Construct aesthetic mappings

aes

Colour related aesthetics: colour, fill, and alpha

aes_colour_fill_alpha color colour fill

Control aesthetic evaluation

aes_eval after_scale after_stat from_theme stage stat

Aesthetics: grouping

aes_group_order group

Differentiation related aesthetics: linetype, size, shape

aes_linetype_size_shape linetype shape size

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

aes_position x xend xmax xmin y yend ymax ymin

Create an annotation layer

annotate

Annotation: Custom grob

annotation_custom

Annotation: log tick marks

annotation_logticks

Annotation: a map

annotation_map

Annotation: high-performance rectangular tiling

annotation_raster

Create a ggplot layer appropriate to a particular data type

autolayer

Tailoring plots to particular data types

automatic_plotting

Create a complete ggplot appropriate to a particular data type

autoplot

Create a layer of map borders

borders

Cartesian coordinates

coord_cartesian

Cartesian coordinates with fixed "aspect ratio"

coord_equal coord_fixed

Cartesian coordinates with x and y flipped

coord_flip

Map projections

coord_map coord_quickmap

Polar coordinates

coord_polar coord_radial

Transformed Cartesian coordinate system

coord_trans

Visualise sf objects

CoordSf coord_sf GeomSf geom_sf geom_sf_label geom_sf_text ggsf StatSf stat_sf

Discretise numeric data into categorical

cut_interval cut_number cut_width

Prices of over 50,000 round cut diamonds

diamonds

Key glyphs for legends

draw_key draw_key_abline draw_key_blank draw_key_boxplot draw_key_crossbar draw_key_dotplot draw_key_label draw_key_linerange draw_key_path draw_key_point draw_key_pointrange draw_key_polygon draw_key_rect draw_key_smooth draw_key_text draw_key_timeseries draw_key_vline draw_key_vpath

US economic time series

economics economics_long

Theme elements

element_blank element_geom element_line element_point element_polygon element_rect element_text margin margin_auto margin_part rel

Expand the plot limits, using data

expand_limits

Generate expansion vector for scales

expand_scale expansion

Lay out panels in a grid

facet_grid

Wrap a 1d ribbon of panels into 2d

facet_wrap

2d density estimate of Old Faithful data

faithfuld

Fortify a model with data.

fortify

Reference lines: horizontal, vertical, and diagonal

geom_abline geom_hline geom_vline

Bar charts

geom_bar geom_col stat_count

Heatmap of 2d bin counts

geom_bin2d geom_bin_2d stat_bin2d stat_bin_2d

Draw nothing

geom_blank

A box and whiskers plot (in the style of Tukey)

geom_boxplot stat_boxplot

2D contours of a 3D surface

geom_contour geom_contour_filled stat_contour stat_contour_filled

Count overlapping points

geom_count stat_sum

Vertical intervals: lines, crossbars & errorbars

geom_crossbar geom_errorbar geom_errorbarh geom_linerange geom_pointrange

Smoothed density estimates

geom_density stat_density

Contours of a 2D density estimate

geom_density2d geom_density2d_filled geom_density_2d geom_density_2d_filled stat_density2d stat_density2d_filled stat_density_2d stat_density_2d_filled

Dot plot

geom_dotplot

Histograms and frequency polygons

geom_freqpoly geom_histogram stat_bin

Draw a function as a continuous curve

geom_function stat_function

Hexagonal heatmap of 2d bin counts

geom_hex stat_binhex stat_bin_hex

Jittered points

geom_jitter

Text

geom_label geom_text

Polygons from a reference map

geom_map

Connect observations

geom_line geom_path geom_step

Points

geom_point

Polygons

geom_polygon

A quantile-quantile plot

geom_qq geom_qq_line stat_qq stat_qq_line

Quantile regression

geom_quantile stat_quantile

Rectangles

geom_raster geom_rect geom_tile

Ribbons and area plots

geom_area geom_ribbon stat_align

Rug plots in the margins

geom_rug

Line segments and curves

geom_curve geom_segment

Smoothed conditional means

geom_smooth stat_smooth

Line segments parameterised by location, direction and distance

geom_spoke stat_spoke

Violin plot

geom_violin stat_ydensity

Extract alt text from a plot

alt_text get_alt_text

Get, set, and modify the active theme

%+replace% get_theme replace_theme set_theme theme_get theme_replace theme_set theme_update update_theme

Create a new ggplot

ggplot

Create a new ggproto object

ggproto ggproto_parent

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

ggsave

Complete themes

theme_bw theme_classic theme_dark theme_gray theme_grey theme_light theme_linedraw theme_minimal theme_test theme_void

Axis guide

guide_axis

Axis with logarithmic tick marks

guide_axis_logticks

Stacked axis guides

guide_axis_stack

Angle axis guide

guide_axis_theta

A binned version of guide_legend

guide_bins

Continuous colour bar guide

guide_colorbar guide_colourbar

Discretized colourbar guide

guide_colorsteps guide_coloursteps

Custom guides

guide_custom

Legend guide

guide_legend

Empty guide

guide_none

Set guides for each scale

guides

A selection of summary functions from Hmisc

hmisc mean_cl_boot mean_cl_normal mean_sdl median_hilow

Label with mathematical expressions

label_bquote

Construct labelling specification

labeller

Useful labeller functions

labellers label_both label_context label_parsed label_value label_wrap_gen

Modify axis, legend, and plot labels

get_labs ggtitle labs xlab ylab

Layer geometry display

layer_geoms

Layer position adjustments

layer_positions

Layer statistical transformations

layer_stats

Set scale limits

lims xlim ylim

'colors()' in Luv space

luv_colours

Calculate mean and standard error of the mean

mean_se

Midwest demographics

midwest

Fuel economy data from 1999 to 2008 for 38 popular models of cars

mpg

An updated and expanded version of the mammals sleep dataset

msleep

Dodge overlapping objects side-to-side

position_dodge position_dodge2

Don't adjust position

position_identity

Jitter points to avoid overplotting

position_jitter

Simultaneously dodge and jitter

position_jitterdodge

Nudge points a fixed distance

position_nudge

Stack overlapping objects on top of each another

position_fill position_stack

Terms of 12 presidents from Eisenhower to Trump

presidential

Explicitly draw plot

plot.ggplot print.ggplot

Format or print a ggproto object

format.ggproto print.ggproto

Quick plot

qplot quickplot

Compute the "resolution" of a numeric vector

resolution

Alpha transparency scales

scale_alpha scale_alpha_binned scale_alpha_continuous scale_alpha_date scale_alpha_datetime scale_alpha_discrete scale_alpha_ordinal

Positional scales for binning continuous data (x & y)

scale_x_binned scale_y_binned

Sequential, diverging and qualitative colour scales from ColorBrewer

scale_color_brewer scale_color_distiller scale_color_fermenter scale_colour_brewer scale_colour_distiller scale_colour_fermenter scale_fill_brewer scale_fill_distiller scale_fill_fermenter

Continuous and binned colour scales

scale_color_binned scale_color_continuous scale_colour_binned scale_colour_continuous scale_fill_binned scale_fill_continuous

Discrete colour scales

scale_color_discrete scale_colour_discrete scale_fill_discrete

Gradient colour scales

scale_color_date scale_color_datetime scale_color_gradient scale_color_gradient2 scale_color_gradientn scale_colour_date scale_colour_datetime scale_colour_gradient scale_colour_gradient2 scale_colour_gradientn scale_fill_date scale_fill_datetime scale_fill_gradient scale_fill_gradient2 scale_fill_gradientn

Sequential grey colour scales

scale_color_grey scale_colour_grey scale_fill_grey

Evenly spaced colours for discrete data

scale_color_hue scale_colour_hue scale_fill_hue

Binned gradient colour scales

scale_color_steps scale_color_steps2 scale_color_stepsn scale_colour_steps scale_colour_steps2 scale_colour_stepsn scale_fill_steps scale_fill_steps2 scale_fill_stepsn

Viridis colour scales from viridisLite

scale_color_ordinal scale_color_viridis_b scale_color_viridis_c scale_color_viridis_d scale_colour_ordinal scale_colour_viridis_b scale_colour_viridis_c scale_colour_viridis_d scale_fill_ordinal scale_fill_viridis_b scale_fill_viridis_c scale_fill_viridis_d

Position scales for continuous data (x & y)

scale_x_continuous scale_x_log10 scale_x_reverse scale_x_sqrt scale_y_continuous scale_y_log10 scale_y_reverse scale_y_sqrt

Position scales for date/time data

scale_x_date scale_x_datetime scale_x_time scale_y_date scale_y_datetime scale_y_time

Use values without scaling

scale_alpha_identity scale_color_identity scale_colour_identity scale_continuous_identity scale_discrete_identity scale_fill_identity scale_linetype_identity scale_linewidth_identity scale_shape_identity scale_size_identity

Scale for line patterns

scale_linetype scale_linetype_binned scale_linetype_continuous scale_linetype_discrete

Scales for line width

scale_linewidth scale_linewidth_binned scale_linewidth_continuous scale_linewidth_date scale_linewidth_datetime scale_linewidth_discrete scale_linewidth_ordinal

Create your own discrete scale

scale_alpha_manual scale_color_manual scale_colour_manual scale_discrete_manual scale_fill_manual scale_linetype_manual scale_linewidth_manual scale_shape_manual scale_size_manual

Scales for shapes, aka glyphs

scale_shape scale_shape_binned scale_shape_continuous scale_shape_discrete scale_shape_ordinal

Scales for area or radius

scale_radius scale_size scale_size_area scale_size_binned scale_size_binned_area scale_size_continuous scale_size_date scale_size_datetime scale_size_discrete scale_size_ordinal

Position scales for discrete data

scale_x_discrete scale_y_discrete

Vector field of seal movements

seals

Specify a secondary axis

derive dup_axis sec_axis

Connect observations

stat_connect

Compute empirical cumulative distribution

stat_ecdf

Compute normal data ellipses

stat_ellipse

Leave data as is

stat_identity

Manually compute transformations

stat_manual

Extract coordinates from 'sf' objects

StatSfCoordinates stat_sf_coordinates

Bin and summarise in 2d (rectangle & hexagons)

stat_summary2d stat_summary_2d stat_summary_hex

Summarise y values at unique/binned x

stat_summary stat_summary_bin

Remove duplicates

stat_unique

Shortcuts for theme settings

subtheme theme_sub_axis theme_sub_axis_bottom theme_sub_axis_left theme_sub_axis_right theme_sub_axis_top theme_sub_axis_x theme_sub_axis_y theme_sub_legend theme_sub_panel theme_sub_plot theme_sub_strip

Modify components of a theme

theme

Housing sales in TX

txhousing

Quote faceting variables

vars