0

I have data across 3 conditions (brain regions: mPFC, HPC, PCC), with 2 categories (people, places) within each condition, and would like to plot it as box plots, similarly to this example plot:

enter image description here

The plot features I need are thus

  • colour-coded inner box (first and third quartiles) and grey outter box (replacing whiskers, thus +/- 1.5 IQR)
  • data points connected across categories
  • small space between categories, larger spaces between conditions
  • thin horizontal line at y=0

I am really struggling to do this in Matlab (tried to customise user functions), and know that other plotting packages - such as matlplotlib and gpplot2, which I have been wanting to learn anyway - can natively do this sort of plot much easier.

Could anyone sketch what kind of commands would be necessary in either (ideally both) of those plotting packages for me to reproduce this kind of plot with my own data?

To make it easier for anyone kind enough to help, I've generated a random dataset structured like the plot above.

z8080
  • 571
  • 3
  • 7
  • 23
  • 1
    [ggstatsplot](https://indrajeetpatil.github.io/ggstatsplot/) or [ggpubr](http://www.sthda.com/english/articles/24-ggpubr-publication-ready-plots/) might have it – Tung Jan 25 '20 at 17:44
  • 1
    https://stackoverflow.com/questions/49417250/connected-points-in-ggplot-boxplot – Tung Jan 25 '20 at 17:45
  • 1
    https://stackoverflow.com/questions/36240695/connect-ggplot-boxplots-using-lines-and-multiple-factor – Tung Jan 25 '20 at 17:45

1 Answers1

1

In R this is definitely possible to do so, using ggplot2 package.

ggplot(data, 
       aes(x = ..., 
           y = ...,color=...)) +
  geom_point(...) + 
  geom_boxplot(...)

Make sure that every variable that has an impact on color and grouping is in the aes()function.

aswillen
  • 11
  • 3