Plotting in R
What may be confusing at first if you look at graphic examples is that R has several independent graphic engines. Think of it like having several drawing artists, every one with his/her own style. You can decide which one you want to use to represent your data. The two main one are
- The standard graphic device, see many examples below
- ggplot2, see here
There are more graphics engines though. Here is a list of graphic packages that are available and how they fit together
Basic plotting example
The basic plotting command for the standard graphics output is plot() - this is a very simple example:
x = 1:10
y = rnorm(10)
plot(x,y)
Links to learn more about R graphics
Here are some (hopefully) useful links on how to do more complicated graphics:
-
See Appendix 3 of the Essential statistics lecture notes
-
Graph example page on APES
-
The Quick-R page has more complete information about everytipe of plot
-
Derek Ogle’s book chapter is a quick but clear introduction to plotting for Fisheries Analyses
-
Paul Maurell’s book, “R Graphics”, is a resource that helps users to master the intricacies of R graphics
-
How to change the font in R charts
-
About changing the background color in plots
-
We can also find a R graphic’s chapter in “An Introduction to R”
-
For “production figures” (i.e. those submitted for publication), see Nature’s Point of View series on scientific graphics (including colour coding, symbols and lines, all from top-notch designers!).
-
In book form, check out Jean-luc Doumonts Trees, Maps and Theorems, or look at some sample pages: pdf
- R Graph Catalog
- Beyond Bar and Line Graphs: Time for a New Data Presentation Paradigm