How to change the values of the x-axis in a line plot

Hello,

how can I change the values of the x-axis in an line-plot?
I do not want to change the range of the values (with the function xlim=c(1:5))
Instead I try to transform the values into another number.

Which command can I use to transform the values of the x-axis, for example in this plot:

y=1:10
x=1:10
plot(x,y,type="l")

into 5,6,7,8,9,19,20,21,22,23,24 (so 1 turns into 5, 2 turns into 6 and so on...)

Thank´s for your help!

I suspect I do not understand what you need. It seems you could do

x2 <- c(5,6,7,8,9,19,20,21,22,23)
plot(x2, y, type = "l")

(I ended x2 at the value 23 so it would have 10 elements, the same as y)

I´m sorry, my example could be misleading. I wanted to know if I could change the individual values of the x-axis into something else. For example turn 1 into the word "apple" and 2 into the word "orange" ... or turn 1 into the random number "46" and 2 into the number "79" and so on.

OK, here is an example.

plot(1:10, 1:10, xaxt = "n")
axis(side = 1, at = 1:10, labels = c("A", "26", "Q", "W", "E", "R", "%^", "App", "!", "B"))

Created on 2021-05-19 by the reprex package (v0.3.0)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.