Bilal Para
Bilal Para

Reputation: 65

Using mathematical expression in legends and ylab

I have a problem in using mathematical expressions in R for plots. For Example:

x=seq(1,10,0.1)
y=log(x)
plot(x,y,"l",xlab=expression(H[alpha]^beta*(P)),ylab=expression(H[tau]^beta*(P)))
legend("bottom",legend=c(expression(H[alpha]^beta*(P),"=1")),cex=1)

In y-axix label, half of the beta is invisible where as in case of x-axix label, it is ok. Also in legends while i am trying to write an expression in single row but it takes two rows, "=1" it takes in second row.

Upvotes: 0

Views: 1864

Answers (1)

Jarle Tufto
Jarle Tufto

Reputation: 240

You could try something like

x=seq(1,10,0.1)
y=log(x)
par(mgp=c(2.5,1,.0))
plot(x,y,"l",xlab=expression(H[alpha]^beta*(P)),ylab=expression(H[tau]^beta*(P)))
legend("bottom",legend=expression(H[alpha]^beta*(P)==1),cex=1,text.width=2)

Upvotes: 1

Related Questions