September 2010
M T W T F S S
« Aug    
 12345
6789101112
13141516171819
20212223242526
27282930  

Working with ggplot, version 2

In my previous post on this issue, I had presented a code that made weighted boxplots and annotated them with boxplot statistics and the mean values. The problem with that code was that it printed these annotations right on the vertical axes of the boxplots. Also, a relatively minor problem was that, when the values of [...]

simple.scatterplot: Two way distributions

John Verzani’s book has a title page that shows a scatterplot with histograms of x and y variables along the two axes. It is a very powerful way of looking at two distributions. The plot was generated through a function simple.scatterplot. The function is made available as part of the UsingR package, which can be installed [...]

Graphics (base, grid and lattice) in RNews

R News 2(2) has papers on grid and lattice packages.
R News 3(2) has papers on base, grid and gridBase.

Essential stuff for anybody trying to master [...]

Working with ggplot

Hadley Wickham’s ggplot is a very interesting package. It makes beautiful graphics, integrates well with some of the other packages to allow you to superimpose the plots of various types of estimates on plots of data. In particular, it uses colours very well. The default colour schemes are aesthetically pleasing. It allows a flexible use of [...]

Page orientation problem in converting postscript files to pdf using ps2pdf

A commonly reported problem with ps2pdf is that it does not always guess the page orientation right.

A neat solution is here http://allendowney.com/essays/orientation/

I just edited the gs_statd.ps to define the wide page and added an alias in my bashrc called widepdf to convert files to pdf in the wide format. It works great now!!

v.

powered by [...]

Postscript graphics from R

Graphics made in R are best saved as postscript files if the files are to be used for printing. This can be done by wrapping your commands (for example, plot) in a postscript device, or by printing the plot to postscript after the plot has been created.

Method 1.

postscript(“filename”,width=x,height=y)

plot commands

dev.off()

 

Method 2.

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 use a particular (say, same) [...]

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, [...]