Search code examples
rplotmath

Intervals in axis labels using plotmath symbols


I want to use plotmath symbols in R to add an interval to the X axis of a plot, such as 3<=X<=4. I know you can do something like:

x=1:10
x1=3
x2=4

plot(x, xlab=substitute(a <= X *""~ X <= b, list(a=x1,b=x2)))

But I cannot remove the second X as it will give me an error. Is this even possible? Or should I do some trick?


Solution

  • Try the following:

    plot(x, xlab=substitute(a <= ~X <= b, list(a=x1, b=x2)))