0% found this document useful (0 votes)
661 views1 page

Base Graphics Cheat Sheet

This document provides a cheatsheet for base graphics parameters in R. It lists graphical parameters that can be set with par() for multiple plots, plot margins, querying the x and y limits, font properties, and element sizes. It also summarizes functions for creating different plot types like bar plots, histograms, line charts, box plots, dot plots, and scatterplots. These include parameters for adding text, axes, axis labels, tick marks, and titles to plots. The cheatsheet concludes with options for removing or adjusting existing plot elements.

Uploaded by

florin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
661 views1 page

Base Graphics Cheat Sheet

This document provides a cheatsheet for base graphics parameters in R. It lists graphical parameters that can be set with par() for multiple plots, plot margins, querying the x and y limits, font properties, and element sizes. It also summarizes functions for creating different plot types like bar plots, histograms, line charts, box plots, dot plots, and scatterplots. These include parameters for adding text, axes, axis labels, tick marks, and titles to plots. The cheatsheet concludes with options for removing or adjusting existing plot elements.

Uploaded by

florin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

R Base Graphics Cheatsheet

SET GRAPHICAL PARAMETERS ADD TEXT


the following can only be set with par()
location size
par () (magnification factor)
axis labels xlab =, ylab =
all elements cex =
multiple mfcol = c(nrow,ncol) plot margins oma = c(bottom, left, subtitle sub =
(outer) top, right) default: axis labels [Link] =
plots mfrow = c(nrow,ncol) title main =
c(0, 0, 0, 0) lines subtitle [Link] =
plot margins mar = c(bottom, left, style tick mark labels [Link] =
top, right) default: query x & y title [Link] =
par (usr) font face font = 1 (plain)
c(5.1, 4.1, 4.1, 2.1) lines limits
2 (bold) 3 (italic)
position
CREATE A NEW PLOT 4 (bold italic) text direction las = 1 (horizontal)
font family family = serif
Bar charts barplot(height, ) Histograms hist(x, ) justification adj = 0 .5 1
sans mono
bar labels [Link] = breakpts breaks = (left, center, right)
border border =
fill color col = ADD TO AN EXISTING PLOT
Line charts plot(x, type = l )
horizontal horiz = TRUE blank|0 Add new plot [any plot function] Lines lines (x,)
line type lty = solid|1 (,add = TRUE) line style lty =
Box plots boxplot(x, ) dashed|2 ex. barplot(x, add = TRUE) line width lwd =
dotted|3
horizontal horizontal = TRUE line width lwd = color col =
Axes axis (side, )
box labels names = location side = 1 2 3 4 Points points (x,)
(bottom, left, top, right) symbol pch =
Dot plots dotchart(x, ) Scatterplots plot(x, )
pch = tick mark:
dot labels labels = symbol
labels labels =
REMOVE ADJUST location at =
remove tick = FALSE color col =
axis labels ann = FALSE allow plotting
rotate text las = 1 (horizontal) fill color bg = (pch: 21-25 only)
out of plot xpd = TRUE
axis, tickmarks, xaxt = n Axis labels mtext (text, ) Text text (x, y, text,)
region
and labels yaxt = n location side = 1 2 3 4 position pos = 1 2 3 4
(bottom, left, top, right) (rel. to x,y) (below, left, above, right)
aspect ratio asp =
(default=center)
plot box bty = n lines to skip line = (from plot
axis limits xlim =, ylim = region, default = 0)
Title title (main,)
position at = x or y-coord axis labels xlab =, ylab =
NOTE: Many of the parameters here axis lines to xaxs = i , (depending on side)
can be also be set in par(). See R yaxs = i (internal subtitle sub =
match
help for more options. axis limits axis calculation)
justification adj = 0 .5 1 title main =
(left, center, right)
Joyce Robbins, joycerobbins1@[Link]

You might also like