Problem using mtext to write onto a jpeg

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem using mtext to write onto a jpeg

georgeshirreff
Dear all,

I am trying to write figures directly to a file using the jpeg() function.

this_ylab=expression(paste("P",sep="")~lambda)
this_xlab=expression(rho)

jpeg("file_name.jpeg",width=100,height=100,units="mm",res=300)

plot(input_values,output_values,pch=16,cex=cex_pt,xlab="",frame.plot=T,ann=F,axes=F)
axis(side=2)
axis(side=1,labels=T,xlab="")
mtext(this_xlab,side=1,line=4,cex=2)
mtext(this_ylab,side=2,line=3,cex=2)

dev.off()


However, I get the following error message:

Error in mtext(this_xlab, side = 1, line = 4, cex = 2) :
  Metric information not available for this device

I could put the argument specifying the x-label in the "plot" function but then I don't control where it goes. When I have used the tiff() function instead I don't have this problem.

I am using R 2.11.1 on Mac OS X 10.7.3


Thanks,
George
Reply | Threaded
Open this post in threaded view
|

Re: Problem using mtext to write onto a jpeg

David Winsemius

On Jul 3, 2012, at 4:01 AM, georgeshirreff wrote:

> Dear all,
>
> I am trying to write figures directly to a file using the jpeg()  
> function.
>
> this_ylab=expression(paste("P",sep="")~lambda)
> this_xlab=expression(rho)
>
> jpeg("file_name.jpeg",width=100,height=100,units="mm",res=300)

Try instead something like:

quartz(file="file_name.jpeg", type="jpeg", width=7,height=7)

And follow-ups should go the R-SIG-Mac mailing list. And please update  
your installation of R.

--
David.

>
> plot
> (input_values
> ,output_values,pch=16,cex=cex_pt,xlab="",frame.plot=T,ann=F,axes=F)
> axis(side=2)
> axis(side=1,labels=T,xlab="")
> mtext(this_xlab,side=1,line=4,cex=2)
> mtext(this_ylab,side=2,line=3,cex=2)
>
> dev.off()
>
>
> However, I get the following error message:
>
> Error in mtext(this_xlab, side = 1, line = 4, cex = 2) :
>  Metric information not available for this device
>
> I could put the argument specifying the x-label in the "plot"  
> function but
> then I don't control where it goes. When I have used the tiff()  
> function
> instead I don't have this problem.
>
> I am using R 2.11.1 on Mac OS X 10.7.3
>
>
> Thanks,
> George
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Problem-using-mtext-to-write-onto-a-jpeg-tp4635258.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [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.

David Winsemius, MD
West Hartford, CT

______________________________________________
[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
|

Re: Problem using mtext to write onto a jpeg

georgeshirreff
Dear David,

In fact just updating R seems to have fixed the problem. There's a lesson. 

Thanks a lot,
George

On 3 July 2012 17:02, David Winsemius [via R] <[hidden email]> wrote:

On Jul 3, 2012, at 4:01 AM, georgeshirreff wrote:

> Dear all,
>
> I am trying to write figures directly to a file using the jpeg()  
> function.
>
> this_ylab=expression(paste("P",sep="")~lambda)
> this_xlab=expression(rho)
>
> jpeg("file_name.jpeg",width=100,height=100,units="mm",res=300)

Try instead something like:

quartz(file="file_name.jpeg", type="jpeg", width=7,height=7)

And follow-ups should go the R-SIG-Mac mailing list. And please update  
your installation of R.

--
David.

>
> plot
> (input_values
> ,output_values,pch=16,cex=cex_pt,xlab="",frame.plot=T,ann=F,axes=F)
> axis(side=2)
> axis(side=1,labels=T,xlab="")
> mtext(this_xlab,side=1,line=4,cex=2)
> mtext(this_ylab,side=2,line=3,cex=2)
>
> dev.off()
>
>
> However, I get the following error message:
>
> Error in mtext(this_xlab, side = 1, line = 4, cex = 2) :
>  Metric information not available for this device
>
> I could put the argument specifying the x-label in the "plot"  
> function but
> then I don't control where it goes. When I have used the tiff()  
> function
> instead I don't have this problem.
>
> I am using R 2.11.1 on Mac OS X 10.7.3
>
>
> Thanks,
> George
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Problem-using-mtext-to-write-onto-a-jpeg-tp4635258.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [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.

David Winsemius, MD
West Hartford, CT

______________________________________________
[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.



If you reply to this email, your message will be added to the discussion below:
http://r.789695.n4.nabble.com/Problem-using-mtext-to-write-onto-a-jpeg-tp4635258p4635292.html
To unsubscribe from Problem using mtext to write onto a jpeg, click here.
NAML