R & RMINC Figures for the impatient

Asked by KateH

Hi again RMINCers,

Referring to the April, 2008, tutorial (http://code.launchpad.net/rminc/1.0/0.5/+download/VBMstats.pdf), I am able to extract values at a certain voxel and do a box-n-whiskers plot of the two groups.

Up pops a nice window showing the graph. But I want to save it to a .png file to use in manuscripts and slide presentations. How does one do that?

Question information

Language:
English Edit question
Status:
Solved
For:
RMINC Edit question
Assignee:
No assignee Edit question
Solved by:
KateH
Solved:
Last query:
Last reply:
Revision history for this message
KateH (kate-hanratty) said :
#1

Thanks again to Jason for pointing me in the right direction.

The introduction to R graphics and printing/display devices is here:

http://cran.r-project.org/doc/manuals/R-intro.html#Device-drivers

But the important news is that you must:

a) specify the device to which R will dump the graphic output

   R> png("my_file.png") # Send graphic output to a 'device' / .png file called "my_file.png"
   R> dev.list() # Shows device names and numbers
   R> dev.set(which=3) # Sets device 3 (png, in this case) to use

b) plot or otherwise generate the graphic data

   R> options(show.signif.stars = FALSE)
   R> voxel <- mincGetVoxel(gf$file, 44, 20, 52)
   R> summary(lm(voxel ~ group, gf))
   R> plot(voxel ~ group, gf)

c) turn off the device so that the graphic content can be sent/written to the specified device

   R> dev.off()

Now there should be a non-empty file called my_file.png that contains the plot you just generated.