Soil texture triangle with plotrix with different soil classes

45 views Asked by At

I am trying to adapt the soil texture triangle plot shown in this question text to the situation in which I have more samples for each area of soil so I just want the labels corresponding to each area. See example data (adapted from the linked question):

area <- c('S1','S1','S1','S2','S2','S2','S3','S3')
sand <- c(76.4,56.9,61.7,64.5,71,70.1,60.5,53.7)
silt<-c(9.3,23.1,23,17.4,13.5,13.4,21.1,30.6)
clay<-c(14.3, 20,15.4,18,15.5,16.6,18.4,15.7)
my_data<-data.frame(area,sand,silt,clay)

I would like to have just three colours in the symbols and in the legend, corresponding to the three areas.

I tried this:

library(plotrix)
area <- c('S1','S1','S1','S2','S2','S2','S3','S3')
sand <- c(76.4,56.9,61.7,64.5,71,70.1,60.5,53.7)
silt<-c(9.3,23.1,23,17.4,13.5,13.4,21.1,30.6)
clay<-c(14.3, 20,15.4,18,15.5,16.6,18.4,15.7)
my_data<-data.frame(area,sand,silt,clay)

soil.texture(my_data[,2:4],col.symbols=1:3,bg.symbols=1:3,point.labels=my_data$area,pch=21,col.grid=3)
legend( x=1, 
        legend=my_data$area,
        col=1:3, 
        fill=1:3 )

But although I got three colours in the symbols I think they don't correspond to the three areas but are just cycled from the first row and I get still 8 classes in the legend (although with three colours only). Any suggestions? Thanks Raffaele

0

There are 0 answers