0

I need to plot a simple graph in R (preferably using plot) with different distance between some x axis values. I have been trying to accomplish this using the axis function with "at" and "label" parameters. However, I think that the final result is not what should be.

As example, suppose x = seq(1,10,by=1) and y = 2*x.

Now, let's plot doing:

plot(x = x, y = y, type='l', xaxt='n'); 
axis(1, c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), 
      at = c(1, 1.1, 1.2, 1.3,1.4,1.5,1.6,1.7,1.8,1.9));

I would expect a thin and tall graph but the resulting plot is:

X axis re-scaled

Why the graph did not respect the new scale of the x axis and replaced the position 2 by 1.1, 3 by 1.2 and so on? How could I do this?

The real graph is something like : real graph

I need to highlight the slope between (x1,y1) to (x2,y2) and between (x3,y3) to (x5,y5). There are 100 values in axis X and If I leave the same space between them in the graph these slopes I mentioned will be imperceptible

I hope I have been clear in my question.

  • 2
    You're not changing the visual parameters at all. Your just saying you want to to write the text 1 through 10 where the x axis is 1 through 2. It is not clear what you are trying to do. Are you trying to just see ```plot(x, y, type='l', xlim = c(1,1.9))```? – Evan Friedland Jun 03 '18 at 16:23
  • @EvanFriedland I need to plot a graph in which I wish to highlight the slope between (x1,y1) to (x2,y2) and between (x3,y3) to (x5,y5). There are 100 values in axis X and If I leave the same space between them in the graph these slopes I mentioned will be imperceptible. – Christian Masdeval Jun 03 '18 at 18:13
  • You're example data has 10 values. And they happen to all have the same slope. Your example expected picture shows an x axis that is logarithmic. Try ```plot(..., log = 'x')``` – Evan Friedland Jun 11 '18 at 22:16

0 Answers0