在不更改标题格式的情况下在R中的点须中添加方括号的方法?

问题描述

我有一个整洁的数据框,其中包含多个模型,这些图表以点须图的形式绘制。下面,我重新创建了一个类似的数据框。该图需要一个标题来解释有关预测变量的信息,并在没有括号的情况下正确格式化,但是在添加括号时,它会在左下角重复。有什么办法可以解决这个问题?我也有兴趣将标题改为放置在图例的下面,但是尝试使用注释和标签也导致格式问题。感谢您的任何帮助! (此外,如果由于“模型”和“术语”已经相同而看起来很奇怪,那么实际代码中的问题在于标准化模型的某些名称以使颜色正确,但在这里不应该成为问题)。 / p>

results_df <- data.frame(
  model = c("Model 1","Model 1","Model 2","Model 3","Model 2"),estimate = c(-0.4890,0.0966,-0.0911,-0.1700,0.3620,0.1980,-2.0920,-1.1620,-1.6910,-1.5320,-0.8340,-1.4350,0.8240,0.9750,0.9650,0.5210,0.9190,0.9560,-0.9580,-0.1950,-1.1470,-2.6430,-1.7420,-2.2500,-2.9990,-1.8100,-1.8270),conf.low = c(-0.6,0.0,-0.2,-0.6,-2.4,-1.8,-1.9,-3.0,-2.0,-5.6,-3.6,-3.8,-1.9),conf.high = c(0.9,1.1,1.0,0.9,0.5,0.7,0.7),term = c("A","B","C","A","D","E","F","G","H","I","J","K","L"),fixed = c("Without Fixed Effects","Without Fixed Effects","With Fixed Effects","Without Fixed Effects"),type = c("Model 1","Model 2")
)
#recode model
results_df$model = results_df$type
#graph with all elements
full_graph = dwplot(results_df,vline = geom_vline(xintercept = 0,colour = "grey60",linetype = 2),dot_args = list(aes(shape = fixed)),whisker_args = list(aes(colour = type)))
#add aesthetics to graph
full_graph = full_graph +
  theme_bw() +
  theme(legend.justification=c(.02,.993),legend.background = element_rect(color="gray90"),plot.title = element_text(hjust = 0.52),plot.caption = element_text(size=8,hjust = 0)) + 
  xlab("Coefficient Estimate") +
  geom_vline(xintercept = 0,linetype = 2) +
  ggtitle("Graph Title") +
  scale_color_manual(name="Model",values=c("#52D871","#17D0E5","#EF5B3D"),na.translate = F)+
  scale_shape_manual(name = "Shape",values=c(16,17,16,17),na.translate = F)+
  scale_fill_manual(name="Model",values = c("#52D871",na.translate = F)+
  labs(caption = "Note:
- notes about predictors
- additional notes
- additional notes
- additional notes
")
#look at graph,no formatting issues
full_graph

Graph after brackets

#add brackets
brackets = list(c("Bracket 1","C"),c("Bracket 2","F"),c("Bracket 3","I"),c("Bracket 4","L"))
full_plot = full_graph %>% add_brackets(brackets)
#look at graph -- caption formatting now weird
full_plot[1]

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...