Open jcpsantiago opened 7 years ago
I'm interested in looking into this -- can you post your favorite tidyverse tutorials/examples so I can get a feel for them and what's involved?
The best IMO are the ones from Hadley himself https://cran.rstudio.com/web/packages/dplyr/vignettes/introduction.html
The critical thing is having the data in what Hadley calls "tidy" i.e. per observation and not per subject. This is how I have my own hypnogram data, so it's not so straight forward to use your plot. I'll look at the code later when I have time, because I would really like to use this in my upcoming paper.
That makes sense. TBH, my coding for lasagna plots started with a wrapper for the base image(), which took a matrix -- it was only later I attempted a ggplot version. Let me give this a little more thought, as I agree that having gglasagna be compliant with the tidyverse philosophy is probably a worthwhile set of edits.
What about writing a geom_lasagna first and then a ggplot wrapper with a simple theme ("gglasagna")?
Probably the easiest way is to piggyback on a stacked geom_bar, minus the stacking.
I'm able to recreate your grouped lasagna plots with a stacked bar plot and the subject per row ones with geom_tile. They don't look as nice as yours though. It would be nice to have every 30sec block as a square. Anyway I digress..
Just found this tasty package! Just what I needed to plot my hypnograms. Are you still using this package? If so, could you some examples using tidyverse techniques? Using them would make gglasagna even tastier I'm sure.
I was planning on creating a new geom to plot hypnograms, but this looks much better.