[R] alternate usage of soil.texture (plotrix)

Jim Lemon jim at bitwrit.com.au
Tue Jul 22 14:02:48 CEST 2008


On Mon, 2008-07-21 at 07:00 -0700, Dylan Beaudette wrote:
> Hi, I have used the soil.texture() function from the plotrix package
> many times and am very pleased that such a function exists in R. I
> have a slightly different need this time, and need some pointers on
> how to accomplish it. Instead of plotting single symbols on the
> triangle, I would like to outline and fill with a transparent color
> several textural classes. For example, if an area had both loam and
> sandy loam, I would like to draw a polygon around the entire loam and
> sandy loam classes.
> 
> Looking at the soil.texture() code, this snippet seems to draw the
> outlines of the texture classes. However, when I try plotting just a
> couple of the segments in these lists I get lines going off the
> original plot.
> 
> 
> h1 <- c(85, 70, 80, 52, 52, 50, 20, 8, 52, 45, 45, 65,
>             45, 20, 20)/100
>         h3 <- c(0, 0, 20, 20, 7, 0, 0, 12, 20, 27, 27, 35, 40,
>             27, 40)/100
>         t1 <- c(90, 85, 52, 52, 43, 23, 8, 0, 45, 0, 45, 45,
>             0, 20, 0)/100
>         t3 <- c(10, 15, 20, 7, 7, 27, 12, 12, 27, 27, 55, 35,
>             40, 40, 60)/100
>         triax.segments(h1, h3, t1, t2, col.lines)
> 
> 
> Apart from a purely manual approach using locator(), is there any way
> to accomplish what I am trying to do with a slight modification to
> soil.texture() ?

Hi Dylan,
I think that what may be happening is that triax.plot changes the
margins on the plot and then restores the margins that were current when
triax.plot was called. If you make the original call with the argument:

no.add=FALSE

you will probably find that your lines are now in the correct place.

Jim



More information about the R-help mailing list