1

我看不到,要弄清楚如何向这个情节添加标签:

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")

产生:

在此处输入图像描述

我试过这个:

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")

基于此处找到的示例:

使用 ggridges 可视化泊松随机样本组

但我无法让它工作。没有什么变化。

我知道这个图表可能不是一个好主意,但我有兴趣看看它的外观以及或多或少地学习如何应用它。

4

0 回答 0