Quantcast

savePlot for Mac and / or Linux?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

savePlot for Mac and / or Linux?

cgenolin
Hi all,

In the package rtlu, I use the function savePlot. It is convenient since
it let the user decide in which graphic format he wants his graph to be
export.
But when I run R CMD check, I get the following message :

>  rtlu(V1,fileOutput="First.tex",textBefore="\\section{Variable 1 to
3}",graphName="V1")
Error in savePlot(filename = nomBarplot, type = type) : can only copy
from 'windows' devices
Calls: rtlu ... r2lUniv -> r2lUniv.factor -> r2lBarplot -> savePlot
Execution halted

I guess this is a compatibility problem with Linux/Mac? Is there
something close to savePlot for Mac / Linux?

Christophe

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: savePlot for Mac and / or Linux?

Guo-Hao Huang
How about pressing ``Print Screen'' to capture image.
However, the simple/smart solution for you is to output data and draw the
same thing by other softwares.
This can save you much time under any operating systems.

                                                                             
                                                    Guo-Hao Huang
--------------------------------------------------
From: "Christophe Genolini" <[hidden email]>
Sent: Monday, December 07, 2009 4:53 PM
To: <[hidden email]>
Cc: <[hidden email]>
Subject: [R] savePlot for Mac and / or Linux?

> Hi all,
>
> In the package rtlu, I use the function savePlot. It is convenient since
> it let the user decide in which graphic format he wants his graph to be
> export.
> But when I run R CMD check, I get the following message :
>
>>  rtlu(V1,fileOutput="First.tex",textBefore="\\section{Variable 1 to
> 3}",graphName="V1")
> Error in savePlot(filename = nomBarplot, type = type) : can only copy from
> 'windows' devices
> Calls: rtlu ... r2lUniv -> r2lUniv.factor -> r2lBarplot -> savePlot
> Execution halted
>
> I guess this is a compatibility problem with Linux/Mac? Is there something
> close to savePlot for Mac / Linux?
>
> Christophe
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: savePlot for Mac and / or Linux?

James W. MacDonald
In reply to this post by cgenolin
Hi Christophe,

No, there isn't anything close to savePlot() on either Linux or MacOS.
But the difference is that savePlot() is used to save something that has
already been plotted. Since your function appears to be intended to give
the user the ability to save something that has yet to be plotted, you
could simply use a switch() statement in the body of your function:


switch(type, pdf = {
pdf("plotname.pdf")
plot(<something>)
dev.off()
},
jpeg = {
jpeg("plotname.jpg")
plot(<something>)
dev.off()
},
png = {
png("plotname.png")
plot(<something>)
dev.off()
})

You can also plot things first and use recordPlot() and replayPlot() to
emulate savePlot(). In addition, you can get tricky and check to see if
the version of R being used is capable of doing a particular plot type
using capabilities() and then trapping errors where the end user wants
to create a plot that their R installation won't do.

Best,

Jim



Christophe Genolini wrote:

> Hi all,
>
> In the package rtlu, I use the function savePlot. It is convenient since
> it let the user decide in which graphic format he wants his graph to be
> export.
> But when I run R CMD check, I get the following message :
>
>>  rtlu(V1,fileOutput="First.tex",textBefore="\\section{Variable 1 to
> 3}",graphName="V1")
> Error in savePlot(filename = nomBarplot, type = type) : can only copy
> from 'windows' devices
> Calls: rtlu ... r2lUniv -> r2lUniv.factor -> r2lBarplot -> savePlot
> Execution halted
>
> I guess this is a compatibility problem with Linux/Mac? Is there
> something close to savePlot for Mac / Linux?
>
> Christophe
>
> ______________________________________________
> [hidden email] 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.

--
James W. MacDonald, M.S.
Biostatistician
Douglas Lab
University of Michigan
Department of Human Genetics
5912 Buhl
1241 E. Catherine St.
Ann Arbor MI 48109-5618
734-615-7826
**********************************************************
Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: savePlot for Mac and / or Linux?

Gustaf Rydevik
In reply to this post by cgenolin
On Mon, Dec 7, 2009 at 9:53 AM, Christophe Genolini
<[hidden email]>wrote:

> Hi all,
>
> In the package rtlu, I use the function savePlot. It is convenient since it
> let the user decide in which graphic format he wants his graph to be export.
> But when I run R CMD check, I get the following message :
>
>   rtlu(V1,fileOutput="First.tex",textBefore="\\section{Variable 1 to
>>
> 3}",graphName="V1")
> Error in savePlot(filename = nomBarplot, type = type) : can only copy from
> 'windows' devices
> Calls: rtlu ... r2lUniv -> r2lUniv.factor -> r2lBarplot -> savePlot
> Execution halted
>
> I guess this is a compatibility problem with Linux/Mac? Is there something
> close to savePlot for Mac / Linux?
>
> Christophe
>
>

I'm not sure I understand exactly what you want, but for easy changing of
the output file type,
I've written this small function. Perhaps it can be of help.

Regards,
Gustaf

-----------------------------------------


###Function by Gustaf Rydevik, 2009-12-03 [hidden email]
## Created to facilitate easy changes in the file format of generated
graphs.
## Gen.device() generates a device function that is a copy of an existing
function, but
## with (possibly) new defaults.
## Wanted.device can be the name of any device you choose:
png(),jpeg(),postcript(),etc.
## if fileEnding is missing, the function uses the Wanted.device name as
file ending.
## I then use My.device in the rest of the script file, meaning that I only
have to change file ##format in one location  (in the argument of
Gen.device()) to do so for all susequent graphs.

Gen.device<-function(Wanted.device="png",fileEnding=NULL,...){
    dots<-list(...)
    ending<-Wanted.device
    Wanted.device<-get(Wanted.device)
    if(!is.null(fileEnding)) ending<-fileEnding
        generated.device<-function(File,...){
        dots2<-list(...)
        File<-paste(File,ending,sep=".")
        dots[which(names(dots)%in%names(dots2))]<-NULL
        do.call(Wanted.device,c(filename=File,dots,dots2))
    }
    return(generated.device)
}


##example
My.device<-Gen.device("png",width=7,height=7,units="in",res=Res<-200)
My.device(File="test")
plot(rnorm(1999))
dev.off()




--
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE
skype:gustaf_rydevik

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Loading...