Boxplot graphics with gradient colored points

Hello,
How can I do a boxplots graphics with this df :

df <- tribble(
  ~Depth, ~20211015, ~20211016, ~20211017, ~20211018, ~20211019
10, 0.5, 0.36, 0.12, 0.45, 0.58
20, 0.25, 0.36,  0.78, 0.15, 0.26
30, 0.12, 0.36, 0.58, 0.47, 0.23
40, 0.19, 0.98, 0.45, 0.32, 0.14
50, 0.14, 0.58, 0.47, 0.26, 0.42
60, 0.36, 0.48, 0.58, 0.14, 0.85 
70, 0.58, 0.75, 0.91, 0.47, 0.25, 
80, 0.54, 0.31, 0.25, 0.41, NA,
90, NA, 0.47, 0.36, 0.45, NA, 
100,NA, 0.71, NA, 0.19, NA,

where we'll have one boxplot for each date and and every points of the graphics will be colored depending of the values (with the gradient)

Thanks

Is this the sort of thing you want to do?

library(tidyverse)
#> Warning: package 'tibble' was built under R version 4.1.2


df <- tribble(
  ~Depth, ~`20211015`, ~`20211016`, ~`20211017`, ~`20211018`, ~`20211019`,
  10, 0.5, 0.36, 0.12, 0.45, 0.58,
  20, 0.25, 0.36,  0.78, 0.15, 0.26,
  30, 0.12, 0.36, 0.58, 0.47, 0.23,
  40, 0.19, 0.98, 0.45, 0.32, 0.14,
  50, 0.14, 0.58, 0.47, 0.26, 0.42,
  60, 0.36, 0.48, 0.58, 0.14, 0.85,
  70, 0.58, 0.75, 0.91, 0.47, 0.25, 
  80, 0.54, 0.31, 0.25, 0.41, NA,
  90, NA, 0.47, 0.36, 0.45, NA, 
  100,NA, 0.71, NA, 0.19, NA)
df |> pivot_longer(-Depth,names_to="Date") |> 
  ggplot(aes(x=Date,y=value))+geom_boxplot()+
  geom_point(aes(color=value))
#> Warning: Removed 6 rows containing non-finite values (stat_boxplot).
#> Warning: Removed 6 rows containing missing values (geom_point).

Created on 2022-07-08 by the reprex package (v2.0.1)

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.