向该ggrig图添加标签

时间:2019-05-28 13:07:27

标签: r ggridges

我看不出来,以了解如何向该图中添加标签:

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

产生:

enter image description here

我已经尝试过了:

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

基于此处找到的示例:

Visualization of Groups of Poisson random samples using ggridges

但是我无法正常工作。没什么改变。

我知道这对这张图可能不是一个好主意,但是我很想了解它的外观,或者或多或少地学习如何使用它。

0 个答案:

没有答案