Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding greek character to axis title

I want to add a greek character to the y-axis of my barplot in R.
The problem is that I need this character to be integrated in the title. I want to write:

Diameter of aperture ("mu"m) 

in the axis label.

With

ylab=expression() 

I can write the greek character, with

ylab="axis title" 

I can write the title with proper spaces between the words.

But I can't find a way to put all these together and write a proper label with a greek word in the axis label. I hope I was clear enough.

like image 730
Rita Avatar asked May 18 '11 12:05

Rita


People also ask

How do you add Greek letters in R?

To make a Greek letter in R, You just use \ and then the name of the letter. If you want a subscript, like β1 , you use $\beta_1$ .

How do you type Greek letters?

First, select the “Greek (abc -> Ελληνικά)” keyboard from the Gboard menu on your Android device. icon in order to select the “Greek (abc -> Ελληνικά)” keyboard. Once the model downloads, you'll be ready to start using the new keyboard! You can either tap or glide type.


2 Answers

If you're using plotmath{grDevices}, the main help page (plotmath) contains an example of what you appear to want:

xlab = expression(paste("Phase Angle ", phi)) 

or for your case, I guess:

ylab = expression(paste("Diameter of aperture ( ", mu, " )")) 

Does this work for you?

like image 184
Nick Sabbe Avatar answered Sep 29 '22 18:09

Nick Sabbe


I think I followed your question properly. The ~ forces a space between characters in a call to expression(). Is this what you want?

plot(1:3, ylab = expression("Diameter of apeture (" * mu ~ "m)"),   , xlab = expression("Force spaces with ~" ~ mu ~ pi * sigma ~ pi)   , main = expression("This is another Greek character with space" ~ sigma)) 

enter image description here

like image 43
Chase Avatar answered Sep 29 '22 18:09

Chase