2
x<-c(0.2,0.4,0.8,2.3)
y4<-c(190.66,185.55,188.53,187.51)
par(mar=c(2.0,4.5,0.5,2.5))
plot(x,y4,type="l",xaxt="n",yaxt="n",col="navy",frame=F,lwd=2,
 xlab="levels(ppm)",ylab=expression(bold(paste("HOMA-",beta,"(%)"))),font.lab=2, 
 xlim=c(0,2.5),ylim=c(185,195))
axis(1,at=c(0,0.5,1.0,1.5,2.0,2.5),lwd=2)
axis(2,at=c(185,190,195),lwd=2)
abline(h=190.66,lty=2)
text(2.0,192, "P for trend<0.01",cex=0.75)

How to make beta italic and bold in axis label and P italic and bold in text? Thank you.

stata
  • 545
  • 1
  • 8
  • 20

1 Answers1

4

From the ?plotmath help page

Note that bold, italic and bolditalic do not apply to symbols, and hence not to the Greek symbols such as mu which are displayed in the symbol font. They also do not apply to numeric constants.

also from the ?plotmath help page

Any Unicode character can be entered into a text string via a \uxxxx escape, or used by number in a call to points. The windows family of devices can display such characters if they are available in the font in use. This can often be used to display Greek letters in bold or italic.

Thus you can plot the beta with

plot(x,y4,type="l",xaxt="n",yaxt="n",col="navy",frame=F,lwd=2,
 xlab="levels(ppm)",xlim=c(0,2.5),ylim=c(185,195), font.lab=2 ,
 ylab=expression(bold("HOMA-")~bolditalic("\u03B2")~bold("(%)"))
 )

and you can use an expression for the "P" in the text

text(2.0,192, expression(bolditalic(P)~bold("for trend<0.01")),cex=0.75)

enter image description here

MrFlick
  • 195,160
  • 17
  • 277
  • 295
  • Thanks. But beta was not italic. I also hope that "for trend<0.01" was bold. – stata Jun 27 '14 at 18:10
  • Very good! Thank you very much! Could you make axis label and text font be Times New Roman? Why my plot had no x axis label? – stata Jun 27 '14 at 18:21
  • Very nice, thanks for the hint about finding the greek character reference - super helpful – Nova Apr 25 '16 at 14:03
  • @stata use `library(extrafont)` and then use `plot(x, y, family = "Times New Roman", ...)`. Hope it will work. – Pankaj Jun 04 '16 at 09:18