[R] tyring to save plots using windoze 7 and cygwin

Joshua Wiley jwiley.psych at gmail.com
Sun Oct 3 01:35:03 CEST 2010


Hi Mike,

I am using Windows 7 x64 with
> sessionInfo()
R version 2.11.1 (2010-05-31)
x86_64-pc-mingw32

First off the Rplots.pdf is created by your call to plot().  Just like
the console output is diverted when running scripts, it does not make
sense to send the graphics to the usual windows device.  This fact
also wreaks a bit of havoc on functions that you might normally use in
an interactive session.  I think the easiest thing to do is just pick
the format you want from the get go.  For instance, in your script
file:

######################################
# Initialize pdf (or whatever) device
pdf("myfile.pdf")
# plot your graph
plot(xyz, main="imp rate", xlab="Time(GMT)",ylab="imp/minute")
# add the grid lines
grid()
# shut the device down
dev.off()
########################################

You would use a similar process for postscript(), png(), etc.  What
version of R are you using?  I do not have the save.plot() function
(at least in the packages that load by default).  You can learn more
by poking around the help pages ?dev.copy ?Devices ?windows

HTH,

Josh

On Sat, Oct 2, 2010 at 3:43 PM, Mike Marchywka <marchywka at hotmail.com> wrote:
>
>
> Hi,
> I'd been using R in the past and recently installed it on a new windoze 7 machine.
> There have been many issues with compatibility and 32/64 bit apps etc and I did
> find on google on isolated complaint that saveplot failed in scripts a long time ago.
> R seems to work fine except script-based plot saving as pdf has not worked.
> I have tried the following, none of which seem to function,
>
>
> xyz <-read.table("time_frac2")
> x=plot(xyz,main="imp rate", xlab="Time(GMT)",ylab="imp/minute")
> grid()
>
> dev2bitmap("xxx.pdf",type="pdfwrite")
> save.plot(x,file="xxx.pdf",format="pdf")
> dev.copy("pdf","auto_pdf.pdf")
> dev.off()
> savePlot("./auto_hit_rate.pdf",type="pdf")
>
> q()
>
>
>
> Now apparently R does save the plot in a default file Rplots.pdf which is
> just fine for my immediate needs but this may have limitations for future
> usages.
>
> Just curious to know what other may have gotten to work or not work.
> Thanks.
>
> - - - - - -
>
> Mike Marchywka | V.P. Technology
>
> 415-264-8477
> marchywka at phluant.com
>
> Online Advertising and Analytics for Mobile
> http://www.phluant.com
>
>
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/



More information about the R-help mailing list