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

Moffet, Corey Corey.Moffet at ttu.edu
Wed Apr 17 18:51:20 CEST 2002


Thank you for your quick response.  Using asp = 1 fixed 1 problem but I
still have the problem with labeling the sand axis.  I have made some
changes to the function so I will include it again and give an example call:

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="", asp = 1, ...)
  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(53, 58, -10), c(-7, 55, 55) ), c("Sand", "Clay", "Silt"),
cex = 0.9 )
  text(conv.ter(c(20,40,60,80,100 ), c(rep(-2, 5)) ), c("20", "40", "60",
"80", "100"), cex = 0.75 )
  text(conv.ter(c(83,63,43,23,3 ), c(20,40,60,80,100) ), c("20", "40", "60",
"80", "100"), cex = 0.75 )
  text(conv.ter(c(rep(-3,5)), c(82,62,42,22,2)), c("20", "40", "60", "80",
"100"), cex = 0.75 )
}

plot.psd(c(33,43,53), c(33,23,13), pch = c("1", "2", "3"), col = c("blue",
"black", "red"), cex = 0.5)


What I am trying to do is replace the default x-axis with a custom axis but
Sand is obscured from view in the R Graphics Device window.  I have used
axes = FALSE, xlab="", ylab="" to clear the defaults and the four text calls
at the bottom of the function are trying to replace the blank defaults with
my custom axis.  What am I missing?

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

-----Original Message-----
From: Martin Maechler [mailto:maechler at stat.math.ethz.ch]
Sent: Wednesday, April 17, 2002 10:30 AM
To: Moffet, Corey
Cc: R-Help (E-mail)
Subject: Re: [R] Problem w/ axis and distortion in a plotting function


Hi Corey,

>>>>> "CoMo" == Moffet, Corey <Corey.Moffet at ttu.edu> writes:

    CoMo> I have a function for plotting soil texture that I am
    CoMo> having a problem with.  The function is:

    ...........

(it would be helpful if together with the function,
 you'd give an example call that we can use as well, i.e., with
 "R builtin" or random (sand <- rnorm(...)) data, so we can
 easily see what you mean) 

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

you have an explicit  xlab = "" -- so why would you expect a label?

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

plot(....,  asp = 1 )  ## !!!

This is found (only?) on  help(plot.default),
a very nice feature and probably much under-used possibility
for specifying and fixing the ASPect ratio.

Does it help?

Martin Maechler <maechler at stat.math.ethz.ch>
http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum  LEO C16	Leonhardstr. 27
ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
phone: x-41-1-632-3408		fax: ...-1228			<><
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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