Yamuna_dhungana
Yamuna_dhungana

Reputation: 663

How to put bquote superscript in between two strings in ggplot axes

I would like to get this string Linear Prediction of Protein (mg/ gm^-1 per kg) in my ggplot y axis. I tried the below syntax, but could not get as desired. What am I missing here?

p + ylab(bquote('Linear Prediction of Protein\n (mg/' ~gm^-1 'per kg soil'))

Upvotes: 0

Views: 253

Answers (1)

B Williams
B Williams

Reputation: 2050

Here is a version you could use to split the lines of text

 + ylab(expression(atop("Linear Prediction of Protein", paste("(mg/g", m^-1, ") per kg soil"))))

Upvotes: 1

Related Questions