0

Please see code below.

I would like to add superscripts to my y-axis, so that my "y.units.vec.time" adds a superscript to whatever choice the user picks from the menu of options.

From what I understand, I cannot use expression() properly outside of ggplot(). Is there a way I can add superscripts to my menu of choices in "y.units.vec.time"?

If I use expression() within ylab(), my input (plot.y.label) will be read literally and placed on the y-axis.

  y.units.vec.conc <- c("M","mM","μM", "nM")
      y.units.vec.time <- c("sec","min","hr", "day")

      y.index.units.1 <- menu(y.units.vec.conc, graphics = FALSE, title = "y-axis: What are the units of concentration?")
      y.index.units.2 <- menu(y.units.vec.time, graphics = FALSE, title = "y-axis: What are the units of time?")

      plot.y.label <- paste("Reaction Rate", y.units.vec.conc[y.index.units.1], y.units.vec.time[y.index.units.2], sep = " ")



      p_sat_curve_1 <- ggplot(data = d_sat_2, mapping = aes(x = sub.conc, y = slope.m)) +
        geom_point(size = 1.5) +
        theme_bw() +
        xlab(plot.x.label) +
        ylab(plot.y.label)
clc
  • 107
  • 6
  • 1
    I am sure there is a better way, but a quick way would be to paste in the unicode character `y.units.vec.time <- c("sec²","min²","hr²", "day²")`. It works for the menu but without your data, I cannot see if the superscript is retained in the ggplot. – LouisMP Nov 05 '19 at 20:34
  • 1
    Please provide a [reproducible minimal example](https://stackoverflow.com/q/5963269/8107362) – mnist Nov 05 '19 at 22:22

0 Answers0