Archives for December, 2006

Superimposing two plots

If you want to give two plot commands, and do not want the second one to wipe out the first one, do the following.   plot(first plot)   par(new=TRUE)   plot(second plot)   This will superimpose the second plot on the first. Note that the two plots may have different scales. To ensure that they […]

scatterplot.matrix

John Fox’s package, “car”, has a very useful scatterplot.matrix (or simply spm) to make scatterplots of pairs from a set of variables. The plot below was created using library(“car”) scatterplot.matrix(~Exppop+Exppphc+literacy+Oppphc, reg.line=lm, smooth=TRUE, span=0.5, diagonal = ‘density’, data=temp) dev.print(jpeg, file=”~/graph-matrix.jpg”, width=500, height=500, pointsize=10)

jitter

jitter is an interesting function that adds a small noise to a vector. A very useful feature if you want to plot data points which have some ties.