Intro Thoughts

Status Quo

library(tidyverse)
library(ggsoiltexture)

Experiment

ggsoiltexture(tibble(sand = c(20, 80),
                     silt = c(15, 10),
                     clay = c(65, 10)),
              show_grid = T,
              class = NULL)

# palmerpenguins::penguins |>
#   remove_missing() |>
#   mutate(bill_length_mm = bill_length_mm / mean(bill_length_mm),
#          bill_depth_mm = bill_depth_mm / mean(bill_depth_mm),
#          flipper_length_mm = flipper_length_mm / mean(flipper_length_mm)) |>
#   mutate(total_length = bill_length_mm + bill_depth_mm + flipper_length_mm) |>
#   mutate(sand = 100*bill_length_mm/total_length) |> 
#   mutate(silt = 100*bill_depth_mm/total_length) |>
#   mutate(clay = 100*flipper_length_mm/total_length) |>
#   ggsoiltexture() + 
#   geom_point(aes(color = species))


snapshot <- ggplyr::intercept

compute_tern_shift <- function(data, scales){
  
  data |> 
    mutate(x = x + y/2 )
  
}


tibble(clay = runif(1000, 0, 100),
       silt = runif(1000, 0, 100),
       sand_random = runif(1000, 0, 100),
       sand_computed = 100 - clay - silt) |> 
  ggplot() + 
  aes(y = clay) + 
  geom_rug() + labs(title = "first dimention, random 0% to 100%") +
  snapshot("p1") +
  scale_x_continuous(position = "top") +
  aes(x = silt) + 
  coord_fixed(sqrt(3)/2) +
  geom_point() +   
  labs(title = "second dimention, random 0% to 100%") +
  snapshot("p2") +
  aes(alpha = (clay + silt) < 100) + 
  labs(title = "highlight possible (does not exceed 100%)") + 
  snapshot("p3") +
  ggplyr::data_filter((clay + silt) < 100) + aes(alpha = NULL) + 
  labs(title = "remove impossible (drop > 100%)") + 
  snapshot("p4") +
  scale_color_viridis_c() +
  aes(color = sand_random) + 
  labs(title = "third dimension, random 0 to 100") + 
  snapshot("p5") +
  aes(color = sand_computed) + 
  labs(title = "third component computed") +
  snapshot("p6") 
## p1
## p2
## p3
## p4
## p5
## p6

ggplyr::last_plot_wipe_last() + 
  geom_point(stat = ggproto("hi", Stat, compute_group = compute_tern_shift)) +
  snapshot("p7")  +
  NULL
## p7

# ggram:::gif_from_ggplots(list(p1, p2, p3, p4, p5, p6, p7))
library(patchwork)
## Warning: package 'patchwork' was built under R version 4.4.1
((p1 + p2)/
(p3 + p4)/
(p5 + p6)) + patchwork::plot_annotation(tag_levels = "A")
## Warning: Using alpha for a discrete variable is not advised.

library(ggsoiltexture)
library(tidyverse)

tibble(clay = runif(1000, 0, 100),
       silt = runif(1000, 0, 100),
       sand_random = runif(1000, 0, 100),
       sand_computed = 100 - clay - silt) |> 
  ggplot() + 
  aes(y = clay) + # axis 1
  aes(x = silt) + # axis 2
  geom_point() +  
  aes(alpha = (clay + silt) < 100) + # highlight possible
  scale_color_viridis_c(limits = c(0,100)) + 
  aes(color = sand_computed) # axis 3
## Warning: Using alpha for a discrete variable is not advised.

tibble(sand = runif(1000, 0, 100),
       silt = runif(1000, 0, 100), 
       clay = 100 - sand - silt) |>
  filter((sand+silt) < 100) |>
  ggsoiltexture() + 
  geom_point(aes(color = sand)) + 
  coord_equal() + 
  scale_color_viridis_c() + 
  NULL
## Coordinate system already present.
## ℹ Adding new coordinate system, which will replace the existing one.