1

I can't see, to figure out how to add labels to this plot:

ggplot(input_cleaned, aes(x =DAYS_TO_FA, y = fct_rev(DATE_TEXT), group = fct_rev(DATE_TEXT))) +
  geom_density_ridges2(stat="binline", bins = 75, scale = 0.95, draw_baseline = FALSE) +
  labs(title = 'Monthly Plots of Time to First Nose Pickin', y='Month Tracked', x = 'Days to First Pickin Action') +
  theme(plot.title = element_text(hjust = 0.5), plot.subtitle = element_text(hjust = 0.5)) + 
  scale_x_continuous(breaks=seq(0,130,5)) + 
  geom_segment(aes(x=50, xend = 50, y=1,yend=5), 
             linetype = "dashed", size = 1.5,
             color = "black") +
  geom_segment(aes(x=75, xend = 75, y=5,yend=30), 
             linetype = "dashed", size = 1.5,
             color = "black")

which produces:

enter image description here

I have tried this:

ggplot(input_cleaned, aes(x =DAYS_TO_FA, y = fct_rev(DATE_TEXT), group = fct_rev(DATE_TEXT))) +
  geom_density_ridges2(stat="binline", bins = 75, scale = 0.95, draw_baseline = FALSE) +
  geom_text(stat = "bin",
            aes(y = fct_rev(input_cleaned$DATE_TEXT) + 0.95*(..count../max(..count..)), label = ifelse(..count..>0, ..count.., "")), 
            vjust = 1.4, size = 3, color = "white", binwidth = 1) +
  labs(title = 'Monthly Plots of Time to First Nose Pickin', y='Month Tracked', x = 'Days to First Pickin Action') +
  theme(plot.title = element_text(hjust = 0.5), plot.subtitle = element_text(hjust = 0.5)) + 
  scale_x_continuous(breaks=seq(0,130,5)) + 
  geom_segment(aes(x=50, xend = 50, y=1,yend=5), 
             linetype = "dashed", size = 1.5,
             color = "black") +
  geom_segment(aes(x=75, xend = 75, y=5,yend=30), 
             linetype = "dashed", size = 1.5,
             color = "black")

based on the example found here:

Visualization of Groups of Poisson random samples using ggridges

but I can't get it to work. Nothing changes.

I know it may not be a good idea for this graph, but I am interested in seeing how it looks and more or less learning how to apply it.

traggatmot
  • 1,423
  • 5
  • 26
  • 51

0 Answers0