Search code examples
rplotaxis-labels

How to add a label to the axis in R?


How can I add a single label to the y-axis of the plot? By default, the plotted labels are e.g. 10, 20, 30, 40 and I'd like to add an extra one such as 18.5 so there will be labels 10, 18.5, 20, 30, 40 in total.

I seek a function like:

append.axis(axis='y', val=18.5)

But I haven't found any. Is it even possible?


Solution

  • e.g.:

     plot(rnorm(100), rnorm(100))
     axis(side = 1, at = 0.5, col.ticks = 'red')
    

    enter image description here

    axis is very flexible: you should read up on it (via ?axis in the first instance).