I have my measurement data in (x, y). I am trying to plot a semi-logarithmic plot of y versus log (x). It looks like that there are two ways to plot such a graph.

  1. Transform the values of x to log (x) for all values of x. Then, I could plot (log x, y) similar to that of plotting (x, y).

  2. Arrange y in log scale (example, for a base of 10, arrange x axis by a decade), and plot the data set exactly like I would plot (x, y) in this logarithmic scale. In other words, I do not need to compute logarithmic values of x. Instead, I could simply rearrange x axis in logarithmic scale and then plot (x, y).

Here are my two questions:

  1. Are both the options discussed above the same thing in terms of data representation? If both methods of plotting are the same, I would assume the slope of data set would be the same using both the methods.

  2. I would like to show that my variable in y is linear with log of the variable in x axis. In order to do so, I plotted the (x, y) data set using the second method of plotting discussed above and did a linear fit. I got a R2 value close to 0.95. Please provide your suggestions about the validity of this method.

Thank you.


The difference between taking logs of the x-values and plotting the x-values on paper with a log-x scale lies in the labeling of the horizontal axis.

In the former case, the x-axis has labels according to the values of $\log(x).$ In the latter case, the (distorted) x-axis has labels according to the values of $x$.

In the plots below, the first plots the data without any attention to logs. In the second, the x-axis has values of $\log(x).$ In the third, the $x$-values are plotted on a log scale. The second and third plots both appear to be roughly linear.

If the scales are appropriate, the slopes will appear to be the same. Numerically, they will not be the same because different numbers are used. In the plot at right, numerically the plot is not really a line, but distorted to look as if it were a line by the log scale on the horizonal axis.

This example uses R and 'logs' are natural logarithms, not logs-base-10.

enter image description here

R code for the three plots:

x0 = rnorm(50, 10, 2);  x = exp(x0)
y = x0 + runif(50, 0, .5)
  plot(x, y)
  plot(log(x), y);  plot(x, y, log="x")

Data description:

    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
   785.3   8664.6  30791.7 106720.1 100116.2 752057.6 
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  6.666   9.067  10.334  10.328  11.514  13.531 

cor(x, y);  cor(log(x), y)  # Pearson correlations
[1] 0.7880628
[1] 0.9958471
cor(x, y, method="spearman");  cor(log(x),y, method="spearman")
[1] 0.9937575
[1] 0.9937575

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.