tags:

views:

80

answers:

2

When I'm generating graphics for publications and talks, I tend to use ggplot2. However, for very large data sets where I want to generate a quick plot or for courses where students don't have a good grounding in R, I use the base graphics.

Are there any nice (simple!) ways of spicing up R graphics? For example, do you use a nice combination of colours and line types. I tend to do something like:

#Functional but not that nice    
plot(x1,y1, type="l")
lines(x2, y2, col=2, lty=2)

In particular, I'm thinking about the plot, hist, and density functions, but I suppose this question applies to all base R graphics.

+5  A: 

Learn to use par. At the very least, make the y-axis label horizontal with par(las = 1). Manually adjusting margins with the mar and oma settings of par are also useful.

Use hue-chroma-luminance (HCL) colours, via the vcd package, especially for plots involving area (histograms or whatever).


The first half of Paul Murrell's R Graphics gives you advice on customising base graphics. If you want more general advice on drawing good graphs, Stephen Few's Now You See It is my personal favourite, and Edward Tufte's books are all staples.


As an alternative to teaching base graphics, you could use latticist to make lattice easier to learn.

Richie Cotton
+1  A: 

Just yesterday I asked a related question (see here).

Besides that, Richie gave the R graphics link, which could be of great use to you.

Also give a look to the R graph gallery since it holds examples with code to many cool things that can be done with base graphics.

Tal Galili