-1

I have a table in R, but the scale of the x- and y-axis is not desirable. How would I scale the x- and y-axis to even out the points on the chart?

I have two values which I want to plot.

p2
[1]     0.061     0.380     1.000
[4]     3.880   140.900   861.460
[7]  7107.180 27262.082 61585.560

a3
[1]     0.058     0.378     1.000
[4]     3.540   140.810   867.910
[7]  7057.800 27155.500 61354.900

plot( 
      p2, 
      a3, 
      main="p2 vs a3", 
      pch=20, 
      type="o" 
  )

The code above gives me the following plot

enter image description here

How would I go about to manipulate the values and scale so that the first couple of values are more prevalent, and presents the plot as a curve rather than a straight line. Something more like this:

enter image description here

slimmey
  • 29
  • 7

1 Answers1

0

Your tag says ggplot2, yet you use the classic R plot.

What you look like seems to be log transformation of the x axis.

For plot:

plot(x = p2, y= a3, main="p2 vs a3", 
  pch=20, type="o",log = "x" 
)

If you want to rescale both axes:

plot(x = p2, y= a3, main="p2 vs a3", 
  pch=20, type="o",log = "yx" 
)

With ggplot2:

qplot(x = p2, y= a3, title="p2 vs a3", 
  size=I(5), geom="point")+scale_x_log10()
DeveauP
  • 1,217
  • 11
  • 21
  • Thank you. Apologies for messing up the clarification around ggplot2. The classic R code works, but the axes legend still needs to be changed from 1e-01 format to decimals. The ggplot2 code gives me an error: could not find function "geom_points" – slimmey Apr 21 '16 at 11:07
  • Sorry, it is a spelling mistake, it should be `"point"` not `"points"`. – DeveauP Apr 21 '16 at 11:13