I am trying to add a subscript to a ggpubr graph, which I found that I can do quite easily using parse
and a set of square brackets. However, the problem is that within the axis label, I have a second set of square brackets that should be in regular type. Something like this:
library(ggpubr)
cars$speed <- log10(cars$speed)
ggscatter(cars, y = "speed", x = "dist", ylab = parse(text = "log[10](speed [μm])"))
I want the base of the logarithm (10) in subscript, but not the distance measure, [μm], which should keep it's brackets and stay in normal font size.
I have tried using paste(parse(text = "log[10]"), "(speed [μm])")
, parse(text = "log[10](speed \\[μm\\]")
and expression
, but these have not worked for me so far.
CodePudding user response:
Alternatively use expression
...
ggscatter(cars, y = "speed", x = "dist", ylab = expression(log[10]*"(speed [µm])"))