[R] Problem w/ axis and distortion in a plotting function

Moffet, Corey Corey.Moffet at ttu.edu
Wed Apr 17 16:24:51 CEST 2002


I have a function for plotting soil texture that I am having a problem with.

The function is:

plot.psd <- function(sand, clay, ...) {
  conv.ter <- function(x, y) {
     x.con <- 100 - x - y*cos(1/3*pi)
     y.con <- y*sin(1/3*pi)
     data.frame(x=x.con, y=y.con)
  }
  plot(conv.ter(sand, clay), xlim = c(0,100), ylim = c(0,100*sin(1/3*pi)),
axes = FALSE, xlab="", ylab="", ...)
  lines(conv.ter(c(100,0), c(0,100)))
  lines(conv.ter(c(100,0), c(0,0)))
  lines(conv.ter(c(0,0), c(0,100)))
  lines(conv.ter(c(85,90), c(0,10)))
  lines(conv.ter(c(70,85), c(0,15)))
  lines(conv.ter(c(50,43,52,52,80), c(0,7,7,20,20)))
  lines(conv.ter(c(43,23,45,52), c(7,27,27,20)))
  lines(conv.ter(c(45,45,65), c(27,35,35)))
  lines(conv.ter(c(45,45), c(35,55)))
  lines(conv.ter(c(45,20,20,23), c(40,40,27,27)))
  lines(conv.ter(c(20,0), c(40,60)))
  lines(conv.ter(c(20,0), c(27,27)))
  lines(conv.ter(c(20,0), c(40,40)))
  lines(conv.ter(c(0,8,20), c(12,12,0)))
  for(i in seq(10, 90, 10)) {
    lines(conv.ter(c(i,i), c(0,(100-i))), lty = 3)
    lines(conv.ter(c((100-i),0), c(i,i)), lty = 3)
    lines(conv.ter(c(i,0), c(0,i)), lty = 3)
  }
  text(conv.ter(c(50, 60, -10), c(-10, 55, 55) ), c("Sand", "Clay", "Silt"),
cex = 0.9 )
  text(conv.ter(c(0,20,40,60,80,100 ), c(rep(-2, 6)) ), c("0", "20", "40",
"60", "80", "100"), cex = 0.75 )
  text(conv.ter(c(103,83,63,43,23,3 ), c(0,20,40,60,80,100) ), c("0", "20",
"40", "60", "80", "100"), cex = 0.75 )
  text(conv.ter(c(rep(-3,6)), c(102,82,62,42,22,2)), c("0", "20", "40",
"60", "80", "100"), cex = 0.75 )
}

The label for the Sand axis (first text line above) is not shown.

The second problem I have with this is that the triangle should be
equilateral but when I print
it the triangle is not.  If I use par(pty = "s") before the plot.psd call
than the triangle is
always stretched vertically.

Any Ideas?


With best wishes and kind regards I am

Sincerely,

Corey A. Moffet
Instructor
Department of Range, Wildlife, and Fisheries Management
Mail Stop 2125
Texas Tech University
Lubbock, Texas 79409-2125
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list