问题描述
我有以下来自Forest plot with subgroups in GGPlot2
的代码我正在尝试: 1-根据我想要的黑白数字更改点形状,但这给了我一条错误消息
geom_point(size=2,values=c(3,16,17),colour="white",stroke = 0.5,position=position_dodge(width = 0.5))
Warning message:
Ignoring unkNown parameters: values
2-在图外添加文本以标记线并具有子组。在所附的代码中,它不会给出错误消息,但不会显示文本。我尝试了其他代码来添加文本,但存在类似问题。
library('ggplot2')
library('Metafor')
library ('grid')
library ('gridExtra')
Outcome_order <- c('cancer 1','cancer 2','cancer 3','cancer 4')
Type_order <- rev(c('age','sex','duration'))
#this is the first dataset you have
First_group <- data.frame(Outcome=c("cancer 1","cancer 2","cancer 3","cancer 4"),Beta=c(-0.064,-0.031,-0.036,-0.083),Lower=c(-0.251,-0.246,-0.260,-0.316),Upper=c(0.122,0.184,0.188,0.149))
# add a group column
First_group$Type <- "age"
# create a second dataset,similar format to first
Second_group <- data.frame(Outcome=c("cancer 1",Beta=c(-0.204,-0.153,-0.201,-0.176),Lower=c(-0.468,-0.456,-0.470,-0.461),Upper=c(0.059,0.151,0.068,0.110))
# add a group column
Second_group$Type <- "sex"
# create a third dataset,similar format to first
Third_group <- data.frame(Outcome=c("cancer 1",Beta=c(-0.123,-0.115,-0.064,-0.093),Lower=c(-0.317,-0.320,-0.236,-0.250),Upper=c(0.072,0.091,0.107,0.065))
# add a group column
Third_group$Type <- "duration"
# combine the three datasets
Graph_data = rbind(First_group,Second_group,Third_group)
# you can do the factoring here
Graph_data$Outcome = factor (Graph_data$Outcome,level=Outcome_order)
Graph_data$Type = factor (Graph_data$Type,levels=(Type_order))
p <- ggplot(Graph_data,aes(x=Outcome,y=Beta,ymin=Lower,ymax=Upper,col=Type,fill= Type)) +
#specify position here
geom_linerange(size=1,position=position_dodge(width = 0.5)) +
geom_hline(yintercept=0,lty=2) +
#specify position here too
geom_point(size=2,position=position_dodge(width = 0.5)) +
scale_color_manual(values=c('#999999','#999999','#999999')) +
scale_y_continuous(name="Group",limits = c(-0.55,0.85),breaks = c(-0.5,-0.25,0.25,0.5,0.75)) +
xlab(NULL)+
coord_flip() +
theme(axis.title.y=element_blank(),axis.text.y=element_blank(),axis.ticks=element_blank(),panel.background = element_blank(),panel.grid.major = element_blank(),panel.grid.minor = element_blank(),axis.line.x = element_line(colour = "black"),legend.position = "none") +
ggtitle("characteristics")+theme(plot.title = element_text(hjust=-0.0))
grid.text(0.5,unit(2,"npc") - unit(2,"line"),label="Label")
p
p + annotate("text",x=3.81,y=-0.3,label="*")
如果您早先回答了我的任何见解和歉意,我将不胜感激。 非常感谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)