# Plot in real unit (1:1)

6 messages
Open this post in threaded view
|

## Plot in real unit (1:1)

 Dear List, Is it possible to plot in R in "real" units? I would like to draw a plot on A4 paper, where 1 plot unit would be a mm in reality. Is something like that possible? I would also like to be able to scale the plot in x and y direction. Background: For a project I would have to draw around 65 fast sketches of elevation courves. Copied from here, due to no answer: https://stackoverflow.com/questions/50606797/plot-in-real-units-mm Thank you! ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: Plot in real unit (1:1)

 Hi Christian, When I have to do something like this, I usually write it in Postscript using this: /def mm 2.8346 mul that converts a dimension in mm to points (1/72 inch). However, this won't work in R. It may be possible to set up the device like this: postscript("myfile.ps",paper="a4") par(mar=c(0,0,0,0)) # generate a blank plot plot(0,type="n",xlim=c(0,210),ylim=c(0,297),axes=FALSE) # display lines, etc. in mm with 0,0 at the bottom left dev.off() The resulting file should be printable. Warning, I don't have time to test this right now. Jim On Thu, Jun 7, 2018 at 12:00 AM, Christian Brandstätter <[hidden email]> wrote: > Dear List, > > Is it possible to plot in R in "real" units? I would like to draw a > plot on A4 paper, where 1 plot unit would be a mm in reality. Is > something like that possible? I would also like to be able to scale the > plot in x and y direction. > Background: For a project I would have to draw around 65 fast sketches > of elevation courves. > > Copied from here, due to no answer: https://stackoverflow.com/questions> /50606797/plot-in-real-units-mm > > Thank you! > > ______________________________________________ > [hidden email] mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: Plot in real unit (1:1)

 Hi Christian, Well, it almost worked. I suspect that the postscript device adds some padding to account for the printable area, so with a bit of experimentation, The following example seems to do what you want. When I printed the resulting file from the GIMP, the box and diamond were the correct dimensions. postscript("test.ps",paper="a4",horizontal=FALSE) par(mai=c(1.713,0,1.713,0),xaxs="i",yaxs="i") plot(0,type="n",xlim=c(0,190),ylim=c(0,190),xlab="",axes=FALSE) segments(c(0,95),c(95,0),c(190,95),c(95,190)) segments(c(45,95,145,95),c(95,145,95,45),  c(95,145,95,45),c(145,95,45,95)) box() dev.off() Jim On Thu, Jun 7, 2018 at 8:16 AM, Jim Lemon <[hidden email]> wrote: > Hi Christian, > When I have to do something like this, I usually write it in > Postscript using this: > > /def mm 2.8346 mul > > that converts a dimension in mm to points (1/72 inch). However, this > won't work in R. It may be possible to set up the device like this: > > postscript("myfile.ps",paper="a4") > par(mar=c(0,0,0,0)) > # generate a blank plot > plot(0,type="n",xlim=c(0,210),ylim=c(0,297),axes=FALSE) > # display lines, etc. in mm with 0,0 at the bottom left > dev.off() > > The resulting file should be printable. Warning, I don't have time to > test this right now. > > Jim > > > > On Thu, Jun 7, 2018 at 12:00 AM, Christian Brandstätter > <[hidden email]> wrote: >> Dear List, >> >> Is it possible to plot in R in "real" units? I would like to draw a >> plot on A4 paper, where 1 plot unit would be a mm in reality. Is >> something like that possible? I would also like to be able to scale the >> plot in x and y direction. >> Background: For a project I would have to draw around 65 fast sketches >> of elevation courves. >> >> Copied from here, due to no answer: https://stackoverflow.com/questions>> /50606797/plot-in-real-units-mm >> >> Thank you! >> >> ______________________________________________ >> [hidden email] mailing list -- To UNSUBSCRIBE and more, see >> 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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: Plot in real unit (1:1)

 Thanks a lot! Jim Lemon <[hidden email]> schrieb am Do., 7. Juni 2018, 06:13: > Hi Christian, > Well, it almost worked. I suspect that the postscript device adds some > padding to account for the printable area, so with a bit of > experimentation, The following example seems to do what you want. When > I printed the resulting file from the GIMP, the box and diamond were > the correct dimensions. > > postscript("test.ps",paper="a4",horizontal=FALSE) > par(mai=c(1.713,0,1.713,0),xaxs="i",yaxs="i") > plot(0,type="n",xlim=c(0,190),ylim=c(0,190),xlab="",axes=FALSE) > segments(c(0,95),c(95,0),c(190,95),c(95,190)) > segments(c(45,95,145,95),c(95,145,95,45), >  c(95,145,95,45),c(145,95,45,95)) > box() > dev.off() > > Jim > > On Thu, Jun 7, 2018 at 8:16 AM, Jim Lemon <[hidden email]> wrote: > > Hi Christian, > > When I have to do something like this, I usually write it in > > Postscript using this: > > > > /def mm 2.8346 mul > > > > that converts a dimension in mm to points (1/72 inch). However, this > > won't work in R. It may be possible to set up the device like this: > > > > postscript("myfile.ps",paper="a4") > > par(mar=c(0,0,0,0)) > > # generate a blank plot > > plot(0,type="n",xlim=c(0,210),ylim=c(0,297),axes=FALSE) > > # display lines, etc. in mm with 0,0 at the bottom left > > dev.off() > > > > The resulting file should be printable. Warning, I don't have time to > > test this right now. > > > > Jim > > > > > > > > On Thu, Jun 7, 2018 at 12:00 AM, Christian Brandstätter > > <[hidden email]> wrote: > >> Dear List, > >> > >> Is it possible to plot in R in "real" units? I would like to draw a > >> plot on A4 paper, where 1 plot unit would be a mm in reality. Is > >> something like that possible? I would also like to be able to scale the > >> plot in x and y direction. > >> Background: For a project I would have to draw around 65 fast sketches > >> of elevation courves. > >> > >> Copied from here, due to no answer: https://stackoverflow.com/questions> >> /50606797/plot-in-real-units-mm > >> > >> Thank you! > >> > >> ______________________________________________ > >> [hidden email] mailing list -- To UNSUBSCRIBE and more, see > >> 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. >         [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.