Closed julianmarenz closed 1 year ago
I agree that would be a good addition to gg_vistime, unfortunately I don't have a handy solution at the moment...
There is one implementation of a legend: https://github.com/wlhamilton/Patient-ward-movement-timelines
I just ran into this issue and found a workaround. First, make a "dummy" plot with the same data that goes into your gg_vistime plot (I used geom_bar) - it doesn't matter how this dummy plot looks, all you need is the legend from it. Once the legend is properly formatted, use get_legend (from ggpubr) to extract the legend from the dummy plot. Finally, use ggarrange (also from ggpubr) to combine your gg_vistime and your extracted legend.
library(vistime) library(ggplot2) library(ggpubr)
Hi!
I am currently using the (great) vistime package to visualize the availability of data during certain periods of time, and their unavailability during others. To do so, I use a green shade when it is available, and a red shade when it is unavailable. Given that there are 22 groups, and sometimes available/NA changes fairly frequently, I was wondering whether there is any way to add a legend to the gg_vistime object that indicates on the side green = available, red = NA? Then there would not be a need to overload the bars themselves with text.