R 在多个面上进行点打印注释

R 在多个面上进行点打印注释,r,ggplot2,R,Ggplot2,这个特别的问题快把我逼疯了!我有一个ggplot,我正试图从这个网站上重新创建它: 除了注释,我已经重新创建了所有内容。我知道我必须创建一个数据框,以便在多个面上进行注释,但点图没有可变的y轴,因此下面的尝试显示了一个错误(我提供了所有代码,因为它相当短): 图书馆(五三八) 图书馆(GG2) 图书馆(dplyr) 图书馆(网格) 图书馆(tidyr) 负责人(第五第三十八名::塔伦蒂诺) 欢迎来到堆栈溢出!你应该提供一份报告。具体地说,我们需要得到您的tarantino_df的一个子集,它会再

这个特别的问题快把我逼疯了!我有一个ggplot,我正试图从这个网站上重新创建它:

除了注释,我已经重新创建了所有内容。我知道我必须创建一个数据框,以便在多个面上进行注释,但点图没有可变的y轴,因此下面的尝试显示了一个错误(我提供了所有代码,因为它相当短):

图书馆(五三八) 图书馆(GG2) 图书馆(dplyr) 图书馆(网格) 图书馆(tidyr) 负责人(第五第三十八名::塔伦蒂诺)


欢迎来到堆栈溢出!你应该提供一份报告。具体地说,我们需要得到您的
tarantino_df
的一个子集,它会再现错误。共享时,请使用
dput(df的子集)
,这样数据集的结构也会被共享。出现特殊错误的原因是您在df中没有的填充上映射了
亵渎
。但是你的权利。即使解决这个问题也无法解决问题,因为y上没有要映射的变量。但这可能会有所帮助。
movie <- c("Reservoir Dogs", "Pulp Fiction", "Jackie Brown", "Kill Bill: Vol. 1", "Kill Bill: Vol. 2", "Inglorious Basterds", "Django Unchained")
start_year <- c(1992,1994,1997,2003,2004,2009,2012)
year_info <- data.frame(movie,start_year)
tarantino_df <-fivethirtyeight::tarantino %>%
  mutate(profane, profane = ifelse(profane == T, "Profanity", "Death"))%>%
  left_join(year_info)%>%
  unite(movie, movie, start_year, sep = ", ")

tarantino_df$movie <- factor(tarantino_df$movie, levels = c("Reservoir Dogs, 1992", "Pulp Fiction, 1994", "Jackie Brown, 1997", "Kill Bill: Vol. 1, 2003", "Kill Bill: Vol. 2, 2004", "Inglorious Basterds, 2009", "Django Unchained, 2012"))
tail(tarantino_df,100)
ann_text<-data.frame(minutes_in=c(25,15),movie=c("Reservoir Dogs, 1992", "Pulp Fiction, 1994"),label=c("Label 1","Label 2"))
tarantino_plot <- ggplot(tarantino_df, aes(x = minutes_in, fill = profane)) + 
      geom_dotplot(binwidth = 1, method = "dotdensity", stackratio = 1.2, aes(color = profane), dotsize = 0.5,      stackgroups = TRUE, binpositions="all", label.select = list(top.up = 10, top.down = 4)) + 
      facet_wrap(~movie, ncol = 1, shrink = TRUE) + 
      scale_color_manual(values =  c("red", "black"))+
      scale_fill_manual(values =  c("red", "black"))+ 
      guides(color = guide_legend(reverse = TRUE))+
      guides(fill = guide_legend(reverse = TRUE))+
      theme(legend.position=c(0.05,1.1), legend.title =element_blank(), plot.margin=unit(c(1.5,1,1.5,1.2),"cm"))+
      scale_y_continuous(breaks=c(0, 20), limits = c(0, 20))+ 
      scale_x_continuous(expand = c(0, 0), limits = c(0, 165))+
      theme(panel.spacing = unit(2, "lines"))+
      theme(strip.text = element_text(hjust = 0),strip.text.x = element_text(size = 10))+
      labs(title = "The complete obscene guide to Tarantino", subtitle = "Time stamp of every instance of profanity and each death in feature films directed by Quentin Tarantino\n\n\n\n\n", x = NULL, y = NULL)+
      geom_text(data = ann_text,label=ann_text$label)

tarantino_plot
Error in FUN(X[[i]], ...) : object 'profane' not found