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

Viewed 3887

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. It only made the tick numbers bold on each axis.

2 Answers
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. If you want the axis labels to be bold you need the argument font.lab=2. I.e., 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")
Related