谁能帮我将 ylab 标题居中?hjust
没有用。XXX 应与 ZZZZ 对齐。您可以在下面看到代码和输出图。
] 1
df4 <- data.frame(min_seg_size=c(1750,2000,2500,3000,1750,2000,2500,3000),
ratio= c(1.075281,1.088825,1.130137,1.056911,
0.9862678,0.9903035,0.9702444,0.995585),
IQ=c( "M","M","M","M",
"F","F","F","F"))
df4$IQ <- factor(df4$IQ, levels=c("M","F"))
scaleY<-seq(0.8,1.3,0.02) ylimt<-c((0.8-0.05), (1.3+0.05))
p192<-ggplot(df4, aes(x=min_seg_size, y=ratio, group=IQ)) +
geom_line(aes(color=IQ))+
geom_point(aes(color=IQ)) + scale_color_manual(values=c("#0072B2","#CC0000")) +
ylab(expression(bold(paste("XXX \n YYY ZZZZ KKK"))) ) + xlab(expression(bold(paste("Minimum Segment Size (kb)"))))+
theme( axis.title.y = element_text(size = 10, margin = margin(t = 0, r =0, b = 0, l = 4, unit = "mm")),
axis.title.x = element_text(size = 10, margin = margin(t = 0, r =0, b = 0, l = 0, unit = "mm")),
panel.background = element_rect(fill = "white", colour = "grey"))+
scale_x_continuous(breaks = c( 1500,1750,2000,2500,3000,3500))+
scale_y_continuous(breaks = c( scaleY))+
theme(
legend.title = element_blank(), legend.text = element_text(size=12)) +
theme( # remove the vertical grid lines
panel.grid.major.x = element_blank() ,
# explicitly set the horizontal lines (or they will disappear too)
panel.grid.major.y = element_line(size=.1, color="black" ) )
p192
删除expression(bold(paste(...
并通过face = "bold"
inside设置字体theme()
:
...也许在“XXX”前面添加一个空格或将多余的“”放在一起,即"XXX\nYYY ZZZZ KKK"
(;
df4 <- data.frame(min_seg_size=c(1750,2000,2500,3000,1750,2000,2500,3000),
ratio= c(1.075281,1.088825,1.130137,1.056911,
0.9862678,0.9903035,0.9702444,0.995585),
IQ=c( "M","M","M","M",
"F","F","F","F"))
df4$IQ <- factor(df4$IQ, levels=c("M","F"))
library(ggplot2)
scaleY<-seq(0.8,1.3,0.02)
ylimt<-c((0.8-0.05), (1.3+0.05))
p192<-ggplot(df4, aes(x=min_seg_size, y=ratio, group=IQ)) +
geom_line(aes(color=IQ))+
geom_point(aes(color=IQ)) + scale_color_manual(values=c("#0072B2","#CC0000")) +
ylab("XXX \n YYY ZZZZ KKK") + xlab("Minimum Segment Size (kb)")+
theme(axis.title.y = element_text(size = 10, face = "bold", margin = margin(t = 0, r =0, b = 0, l = 4, unit = "mm")),
axis.title.x = element_text(size = 10, face = "bold", margin = margin(t = 0, r =0, b = 0, l = 0, unit = "mm")),
panel.background = element_rect(fill = "white", colour = "grey"))+
scale_x_continuous(breaks = c( 1500,1750,2000,2500,3000,3500))+
scale_y_continuous(breaks = c( scaleY)) +
theme(
legend.title = element_blank(), legend.text = element_text(size=12)) +
theme( # remove the vertical grid lines
panel.grid.major.x = element_blank() ,
# explicitly set the horizontal lines (or they will disappear too)
panel.grid.major.y = element_line(size=.1, color="black" ) )
p192
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句