An Overview of R Graphics

R includes tools for drawing most common types of charts, including bar charts, pie charts, line charts, and scatter plots. Additionally, R can also draw some less familiar charts like quantile-quantile (Q-Q) plots, mosaic plots, and contour plots. The following table shows many of the charts included in the graphics package.

Graphics package functionDescription
barplotBar and column charts
dotchartCleveland dot plots
histHistograms
densityKernel density plots
stripchartStrip charts
qqnorm (in stats package)Quantile-quantile plots
xplotScatter plots
smoothScatterSmooth scatter plots
qqplot (in stats package)Quantile-quantile plots
pairsScatter plot matrices
imageImage plots
contourContour plots
perspPerspective charts of three-dimensional data
interaction.plotSummary of the response for two-way combinations of factors
sunflowerplotSunflower plots

You can show R graphics on the screen or save them in many different formats. Graphics Devices explains how to choose output methods. R gives you an enormous amount of control over graphics. You can control almost every aspect of a chart. Customizing Charts explains how to tweak the output of R to look the way you want. This section shows how to use many common types of R charts.

Scatter Plots

To show how to use scatter plots, we will look at cases of cancer in 2008 and toxic waste releases by state in 2006. Data on new cancer cases (and deaths from cancer) are tabulated by the American Cancer Society; information on toxic chemicals ...

Get R in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.