Intro

Cargando paquetes / Loading libraries

install.packages("soiltexture","ggtern","ggplot2")
library(soiltexture)
library(ggtern)
library(ggplot2)

Creamos un data.frame / Creating a data.frame

soils <- data.frame(SAND = c(20,30,40,50,70,10,10),
                    SILT = c(5,15,20,25,20,50,70),
                    CLAY = c(75,55,40,25,10,40,20),
                    OM   = c(2,3,2,5,4,10,4))

soiltexture package / paquete soiltexture

TT.plot(class.sys = "USDA.TT", # Clases texturales según la USDA / USDA textural classes
        tri.data  = soils # Nuestro dataset / our dataset
        )

TT.plot(class.sys = "USDA.TT",
        tri.data  = soils,
        main      = "USDA", # Título / title
        cex.axis  = 0.5, # Expansion factor for axis / Factor de expansión para los ejes
        cex.lab   = 0.5, # Expansion factor for labels / Factor de expansión para las etiquetas 
        col       = "green", # Color for points / Color de los puntos
        z.name    = "OM" #Cuarta variable /4th variable
        )

ggtern package / paquete ggtern

theme_set(theme_bw()) #simple ggplot theme / tema de ggplot simple 

ggtern(data=soils,aes(x=SAND,y=CLAY,z=SILT,color=OM)) + 
  geom_point(size=5) + # tamaño de los puntos / point size
  labs(yarrow="Clay(%)", # etiqueta de las fechas / arrow label
       zarrow="Silt(%)",
       xarrow="Sand(%)") +
  theme_showarrows() + # mostrar flechas / display arrows
  scale_colour_gradient(low = "yellow",# escala de color / color scale
                        high = "red") +
  theme_clockwise() # orientacion de las flechas / arrow orientation /