我想改变中线的颜色geom_boxplot().我看了,找不到办法做到这一点.我在这里发布了我正在使用的R代码,但我真的需要一个如何改变颜色的参考.
ggplot(invitro2) +
geom_boxplot(aes(x = reorder(CANCER_TYPE,tmedian), y = GeoMedian_IC50)) +
xlab("") +
geom_point(aes(x = reorder(CANCER_TYPE,tmedian), y = GeoMedian_IC50)) +
theme_bw() +
scale_y_log10(breaks = trans_breaks("log10", function(x) 10^x),
labels = trans_format("log10", math_format(10^.x))) +
annotation_logticks(sides="l") +
theme(axis.text.x=element_text(angle=45,size=10,hjust=1),
panel.grid.major = element_blank())
Run Code Online (Sandbox Code Playgroud)
use*_*650 13
您可以使用绘图的细节,导出中线所在的坐标,然后使用添加颜色geom_segment.
library(ggplot2)
p <- ggplot(mtcars, aes(factor(am), mpg)) + geom_boxplot()
dat <- ggplot_build(p)$data[[1]]
p + geom_segment(data=dat, aes(x=xmin, xend=xmax,
y=middle, yend=middle), colour="red", size=2)
Run Code Online (Sandbox Code Playgroud)
还必须增加size线,使其覆盖原始的黑色中线