我有下面的代码生成该图。
cols <- brewer.pal(n = 3, name = 'Dark2')
p4 <- ggplot(all.m, aes(x=xval, y=yval, colour = Approach, ymax = 0.95)) + theme_bw() +
geom_errorbar(aes(ymin= yval - se, ymax = yval + se), width=5, position=pd) +
geom_line(position=pd) + geom_point(position=pd) +
geom_hline(aes(yintercept = cp.best$slope, colour = "C2P"), show_guide = FALSE) +
scale_color_manual(name="Appraoch", breaks=c("C2P", "P2P", "CP2P"), values = cols[c(1,3,2)]) +
scale_y_continuous(breaks = seq(0.4, 0.95, 0.05), "Test AUROC") +
scale_x_continuous(breaks = seq(10, 150, by = 20), "# Number of Patient Samples in Training")
p4 <- p4 + theme(legend.direction = 'horizontal',
legend.position = 'top',
plot.margin = unit(c(5.1, 7, 4.5, 3.5)/2, "lines"),
text = element_text(size=15), axis.title.x=element_text(vjust=-1.5), axis.title.y=element_text(vjust=2))
p4
如何仅在“ C2P”的图例中将符号更改为不带点的行,而又不影响“ P2P”和“ CP2P”的符号?
您可以使用override.aes
以下代码从图例中删除点标记:将以下代码行添加到绘图中:
guides(colour=guide_legend(override.aes=list(shape=c(NA,16,16))))
override.aes
更改图例而不更改情节。在这种情况下,我们要更改图例点标记,因此我们要更改shape
点的。点标记数字16是一个实心圆(请参阅参考资料?pch
),我们想保留其中两个标记,但是我们NA
用来删除图例中第一项的点标记。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句