Skip to content
Prev 376834 / 398502 Next

Plot in real unit (1:1)

Dar Jim, 
late, but it works now perfectly. I made a little function for
autoscaling elevation data. 
https://stackoverflow.com/questions/50606797/plot-in-real-units-mm/52696705#52696705The
 (paper-)printer typically also autoscales, which needs to be
deactivated.  
Example for a plot with scale  in y and x direction: 
in2mm<-25.4

mx = 1000 # Scale X # input unit m
my = 2000 # Scale Y # input unit m

pdf("test_size.pdf",width=210/in2mm,height=297/in2mm,paper="special")
par(mar= c(5.1,4.1,4.1,1.1))
pin <- par("pin") # returns plotheight and -width

yvalue <- sort(sample(1:1000,200))
xvalue <- sort(sample(1:500,200))

xplus <- diff(range(c(0,pin[1]*in2mm)))*(mx/1000)/2
yplus <- diff(range(c(0,pin[2]*in2mm)))*(my/1000)/2

plot(xvalue,yvalue,#asp=mx/my,
     type="n", xaxs="i", yaxs="i",
     xlim=c(mean(xvalue)-xplus,mean(xvalue)+xplus),
     ylim=c(mean(yvalue)-yplus,mean(yvalue)+yplus),
     ylab="vertical [m]",xlab="horizontal [m]")

lines(xvalue,yvalue,type="l",col="black")

legend(x="topleft",horiz=TRUE,
       legend=c(paste0("Mx: 1:",mx),paste0("My: 1:",my),
                paste0("Vertical Exaggeration:
1:",mx/my)),x.intersp=0,bty="n")

dev.off()
On Thu, 2018-06-07 at 14:13 +1000, Jim Lemon wrote:

  
  
Message-ID: <a0319513f459fae8ffdadb47352d1cbabc91b04a.camel@gmail.com>
In-Reply-To: <CA+8X3fUGK9FiKdGVudST=Ly-hLiudVWg1MYO_tRjewBLAA6JzA@mail.gmail.com>