Re: [R] losing line of mtext when saving to png format

From: John Kane <jrkrideau_at_yahoo.ca>
Date: Sun, 13 Jun 2010 12:42:38 -0700 (PDT)


Oh, how embarrassing! I made the exact same mistake about 2-3 years ago.

Thanks a lot.

It was not even that important a graph but it was really bothering me.

> From: Joshua Wiley <jwiley.psych_at_gmail.com>
> Subject: Re: [R] losing line of mtext when saving to png format
> To: "John Kane" <jrkrideau@yahoo.ca>
> Cc: "R R-help" <r-help_at_stat.math.ethz.ch>
> Received: Sunday, June 13, 2010, 3:32 PM
> Hey John,
>
> I believe this issue is that the png device is different
> from the
> onscreen one.  You set the margins for the on screen
> with a call to
> par() but not for the png().  The code below works for
> me.
>
> ################
> mydata  <-
> data.frame(kel=c(13,253,263,273,283,292,303,313,323,333,573,853),
> cent=c( -280, -40, -30, -20, -10, 1, 10, 20, 30, 40, 280,
> 560))
> png("C:/Rjunk/brendengraph.png", width=600, height=600)
> par(mar=(c(5, 4, 6, 2))) #this goes after the call to
> png()
> plot(1:12,mydata$kel, main=" ", xlab=" ", ylab="
> ",type="l",
> col="red", xaxt="n", yaxt="n",cex=.75)
> axis(1, at=1:12,labels=as.character(mydata$kel),
> cex.axis=.75)
> axis(3, at=1:12, labels=as.character(mydata$cent),
> cex.axis=.75)
> mtext(side = 1, line=2, text="Degrees Kelvin",cex=.75 )
> mtext(side = 3, line=2, text="Degrees Centegrade",cex=.75
> )
> mtext(side = 3, line=4, text="Room Temperature", font=2,
> cex=.85)
> dev.off()
> #################
>
> HTH,
>
> Josh
>
> On Sun, Jun 13, 2010 at 12:09 PM, John Kane <jrkrideau_at_yahoo.ca>
> wrote:
> >
> > I have a simple graph (oode below) which looks fine on

> the screen but when
> > I save it in png format the title (actually the last
> mtext line) is cut off.
> >
> > I am pretty sure that I am doing something very stupid
> but
> > other than playing around with the png height and
> width commands which don't seem to help I have no idea of
> what to look for.
> >
> > Any suggestions or cures would be appreciated.
> >
> > Thanks
> >
> #===============================================================#
> >
> > mydata  <- data.frame(kel =
> c(13,253,263,273,283,292,303,313,323,333,573,853),
> >              cent=  c( -280, -40, -30, -20,
> -10, 1, 10, 20, 30, 40, 280, 560))
> > (intervals <- diff(mydata[,1]))
> >
> > opar <- par(mar= (c(5, 4, 6, 2)))
> >
> > # png("C:/Rjunk/brendengraph.png", width=600,
> height=500)
> >
> > plot(1:12,mydata$kel, main=" ", xlab=" ",
> >       ylab=" ",type="l", col="red", xaxt="n",
> yaxt="n",cex=.75)
> >
> > axis(1, at=1:12,labels=as.character(mydata$kel),
> cex.axis=.75)
> >
> > axis(3, at=1:12, labels=as.character(mydata$cent),
> cex.axis=.75)
> >
> > mtext(side = 1, line=2, text="Degrees Kelvin",cex=.75
> )
> > mtext(side = 3, line=2, text="Degrees
> Centegrade",cex=.75 )
> > mtext(side=3, line=4, text="Room Temperature", font=2,
> cex=.85)
> > # dev.off()
> > par(opar)
> >
> #=================================================================
> >
> > ______________________________________________
> > 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
> Senior in Psychology
> University of California, Riverside
> http://www.joshuawiley.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. Received on Sun 13 Jun 2010 - 19:44:43 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 13 Jun 2010 - 20:00:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive