简体   繁体   English

R:为图中的图例和 xlab 和 ylab 参数设置粗体文本?

[英]R: make the text bold for the legend and the xlab & ylab parameters in a plot?

I must make all of the text in my plot bold.我必须使情节中的所有文本都加粗。

I am plotting densities using this:我正在使用这个绘制密度:

par(mfrow=c(1,1),family="serif")

plot(density(rxyTop30),col="green",lty=1,lwd=3,bty="l",main="",
xlab=expression(paste(R[xy])),xlim=c(0.0,0.5),ylim=c(0,12),font=2)
 lines(density(jfTop30),col="blue",lty=1,lwd=3)
  legend("topright",c(expression(paste(R[xy]," with 30 ancestors with most 
  progeny"),paste(beta," (",alpha," = 0.96",", ",beta, " = 8.031)"))),
  lwd=c(3,3),lty=c(1,1),col=c("green","blue"),bty="n")

I tried inserting font=2 in different places within the code.我尝试在代码中的不同位置插入font=2 It only made the tick numbers bold on each axis.它只使每个轴上的刻度数字变粗。

a <- 2
b <- 5
plot(a,b)
legend("topleft", legend = c(as.expression(bquote(bold("Bold"))),
                             as.expression(bquote("Not Bold"))))

result结果

The argument font controls the state of the tick numbers.参数font控制刻度数字的状态。 If you want the axis labels to be bold you need the argument font.lab=2 .如果您希望轴标签为粗体,则需要参数font.lab=2 Ie, the following code...即,以下代码...

plot(density(rxyTop30),col="green",lty=1,lwd=3,font.lab=2,bty="l",main="",
xlab=expression(paste(R[xy])),xlim=c(0.0,0.5),ylim=c(0,12),font=2)
 lines(density(jfTop30),col="blue",lty=1,lwd=3)
  legend("topright",c(expression(paste(R[xy]," with 30 ancestors with most 
  progeny"),paste(beta," (",alpha," = 0.96",", ",beta, " = 8.031)"))),
  lwd=c(3,3),lty=c(1,1),col=c("green","blue"),bty="n")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM