USDA Textural Soil Classification
Included in the next version (1.0.3.1) of ggtern, will be a new data set, taken from the USDA Textural Soil Classification[1] which we can use to reproduce the original diagram published by the United Stated Department of Agriculture.
Firstly let us load the packages and data:
# Load the required libraries library(ggtern) library(plyr) library(grid) # Load the Data. (Available in ggtern 1.0.3.0 next version) data(USDA) # Put tile labels at the midpoint of each tile. USDA.LAB = ddply(USDA, 'Label', function(df) { apply(df[, 1:3], 2, mean) }) # Tweak USDA.LAB$Angle = 0 USDA.LAB$Angle[which(USDA.LAB$Label == 'Loamy Sand')] = -35
Reconstructing the USDA’s Original Plot
Now let us construct the plot from the prepared data
# Construct the plot. ggplot(data = USDA, aes(y=Clay, x=Sand, z=Silt)) + coord_tern(L="x",T="y",R="z") + geom_polygon(aes(fill = Label), alpha = 0.75, size = 0.5, color = 'black') + geom_text(data = USDA.LAB, aes(label = Label, angle = Angle), color = 'black', size = 3.5) + theme_rgbw() + theme_showsecondary() + theme_showarrows() + custom_percent("Percent") + theme(legend.justification = c(0, 1), legend.position = c(0, 1)) + labs(title = 'USDA Textural Classification Chart', fill = 'Textural Class', color = 'Textural Class')
Comparison to Existing Format
The above reproduction looks considerably better than the originally published format [1].
Adding Additional Points
A number of people have asked how to add additional points, try the following:
df <- data.frame(SAND=runif(10),SILT=runif(10),CLAY=runif(10)) last_plot() + geom_point(data=df,aes(y=CLAY,x=SAND,z=SILT))
References





Comments