| texture_triangle | R Documentation |
Creates a USDA texture triangle with filled texture-class regions,
USDA class boundary lines, class name labels, and optional data points —
all using a pure ggplot2 ternary-to-Cartesian projection (Clay at top,
Sand at bottom-left, Silt at bottom-right). No external ternary-plot
package is required.
texture_triangle(
df,
sand_col = "sand_total",
silt_col = "silt",
clay_col = "clay",
color_col = NULL,
title = "Soil Texture Triangle",
point_size = 3,
alpha = 0.85
)
df |
A data frame. |
sand_col |
Column name for sand (default |
silt_col |
Column name for silt (default |
clay_col |
Column name for clay (default |
color_col |
Column name for colouring data points (default |
title |
Plot title. |
point_size |
Point size (default |
alpha |
Point transparency (default |
The background is always coloured by USDA texture class (12-class
USDA-inspired palette). Data points are overlaid and can be mapped to a
separate variable via color_col.
A ggplot object.
df <- data.frame(sand_total = c(70, 20, 10, 40),
silt = c(15, 50, 30, 40),
clay = c(15, 30, 60, 20),
Texture = c("Sandy Loam", "Silt Loam", "Clay", "Loam"))
texture_triangle(df, color_col = "Texture")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.