a reproducible gallery of statistical graphics
This cheat sheet shows a few commonly used plotting symbols and color palettes in R. Now you do not need to memorize the facts like “19 is the big solid dot and 21 is an open circle that can have a different background color” – just bookmark this cheat sheet. In fact it was motivated by Dr Rafael Irizarry, who printed the color palettes on a piece of paper and pinned that to the wall in his office.
There are many plotting symbols in the graphics package. We can set the pch
parameter to set
the symbols. See ?points
for more information.
Below is a figure containing the plot symbols from pch = 0
to 25
along with some
character-based plot symbols. We can use, for example, plot(x, y, pch = 3)
for plus signs (+
)
in a scatterplot.
The default color palette in R:
Below are the color palettes in RColorBrewer (if you do not want to use ggplot2, you should
consider using this package to generate colors for your plots; just do not use the meaningless
rainbow()
palette):
In R, the function colors()
returns a vector of 657 color names. When you really
need to specify the color by its name, you are recommended to check out this nice color
chart created by Earl F.
Glynn.