[This article was first published on ggtern: ternary diagrams in R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
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, color = Label, fill = Label)) + coord_tern(L="x",T="y",R="z") + geom_polygon(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), axis.tern.padding = unit(0.15, 'npc')) + 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].
References
[1] Unknown-Author, Soil Mechanics Level 1, Module 3, USDA Textural Classification Study Guide, United States Department of Agriculture, 1987.
[Bibtex]
[Bibtex]
@BOOK{usda, title = {Soil Mechanics Level 1, Module 3, USDA Textural Classification Study Guide}, publisher = {United States Department of Agriculture}, year = {1987}, author = {Unknown-Author}, owner = {Nick Hamilton}, timestamp = {20140116} }
The post USDA Textural Soil Classification appeared first on ggtern: ternary diagrams in R.
To leave a comment for the author, please follow the link and comment on their blog: ggtern: ternary diagrams in R.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.