Superimposing two plots
December 20, 2006 at 11:57 am | In GNU-R, Graphics | 2 CommentsIf 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 use a particular (say, same) scale, set ylim and xlim in both the graphs. If you are using the same scales, you may want to turn off axes and labels in the second plot. Otherwise, they will be printed again.
scatterplot.matrix
December 20, 2006 at 11:55 am | In GNU-R, Graphics | Leave a CommentJohn 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
December 20, 2006 at 11:52 am | In GNU-R | Leave a Commentjitter 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.
Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.
