0

I am trying to visualize my data of biomass for various size classes at different sampling depths - depths are used multiple times for each size class.

I would like to use a violin plot or something similar, as I think it would be good to show the average Biomass at varying depths. However, I am unsure if that is possible with two continuous variables (depth, biomass).

Is there a possible way to visualize this data in violin plots? I have been trying to modify the below chunk of code with no luck. I have attempted grouping by SizeBin, coloring by SizeBin, etc. Any insight on code or alternatives is appreciated.

ggplot(data_frame, aes(x=Depth, 
             y=Biomass,
             fill=SizeBin)) + geom_violin()
Depth Biomass SizeBin
1.5 6.86 A
2.5 3.51 A
2.5 2.45 A
1.5 0.80 B
2.5 1.34 B

1 Answers1

1

You can try to split the violin plot. Here's how to do it: https://r-charts.com/distribution/split-violin-plot/

Or this: Split violin plot with ggplot2

I personally really like those plots.

CodingBiology
  • 262
  • 4
  • 13