Monday, 2 June 2014

Publication quality figures from R....

I have been preparing figures for Suliman's revised manuscript.
This has been a bit of an R learning curve as I have had to prepare the figures in a publication quality format.

However, I have done it and it's progress.

Firstly a list of resources that give some good tips and info:


So the key bit of code is as follows:


>ppi=600    #pixels per square inch
>png("boxplot_20140602.png", width=6*ppi, height=5*ppi, res=ppi)  
              #this creates the output file and adds information about size and resolution  
>boxplot(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, 
               frame=FALSE,   #suppresses the frame
               las =2,                 #turns the labels sideways
               names = c("Patient 1","Patient 2","Patient 3","Patient 4","Patient 5","Patient 6","Patient 7","Patient 8","Patient 9","Patient 10","Patient 11","Patient 12"), 
               yaxt="n",             #suppresses the y axis
               ylab = expression(bold("Relative iTRAQ signal")))
>axis(2, 
         0:4,
         labels=formatC(seq(0,4, by=1)), 
        las=1, 
        xpd=NA)  # allows the axis to go outside of the graph area and plot "0" and "4"
   #  This creates a new axis. 
   # R won't usually let the axis go outside the 'graph area'.

>dev.off()
    #very important command that tells R that you are finished plotting; otherwise your graph will not show up.

Some key concepts:
    This generates PNG files but similar commands are also available for PDFs, SVGs and others. VERY POWERFUL. 
    Increasing the resolution makes the lines thicker and the text more distinct. 

I used PNG to put into Powerpoint. 
Need to learn more about colour. 

No comments:

Post a Comment