2
$\begingroup$

If there is a exponential relationship $y = e^x$ and we take the logarithm of this we can see a linear relationship $\ln (y) = x$. So we could plot the logarithm of the y-axis values against the x values. Why does matlab do loglog plots, where the x-axis is also presented in logarithms? I see many plots where this is done.

Wouldn't using semilogy suffice? Or does using loglog or semilogy actually make no difference for a particular reason?

  • 1
    What @Raskolnikov's comment hints at is that loglog plots are designed to detect (approximate) **power laws** such as $y=cx^a$. To detect **exponential laws**, one would use semilog plots, as you suggest.2011-11-01

2 Answers 2

5

Besides looking for exponential relationships, one might also want to track power law relationships. As Didier and I pointed out, log-log plots are ideal for the task because they reduce any power law relationship to a linear relationship. The exponent then becomes the slope of the graphic, as seen from

$y=c x^a \Leftrightarrow \log y = a \log x + \log c$

Also see this question.

2

I ran into this old question, and I think it needs a little updating.

In communication engineering (and I would think in many other fields too) using $\operatorname{loglog}$ is very common whenever you need to plot a quantity that has a huge dynamic range in both $x$ and $y$ axes. For example, in signal processing one often computes the power spectrum of a signal. The result most likely spans many decades in frequency and many decades in amplitude. $\operatorname{loglog}$ allows you to do be able to see the result, which otherwise would be hard to interpret using any other plotting function.

I think that on a day to day basis this happens way more frequently than attempting to detect power laws. Commercial instruments that perform RF measurements are commonly setup to show both $x$ and $y$ axes in a $\operatorname{loglog}$-like fashion, for the reason I just mentioned.

See this simple example (originally from here), and try to replace loglog with plot, semilogx and semilogy. You'll see that only loglog allows you to see a meaningful plot.

Fs = 1000; t = 0:(1/Fs):1000; x = sin(pi*t); [Pxx, f] = pwelch(x, [], [], [], Fs); loglog(f, Pxx) grid on xlabel('Frequency (Hz)') ylabel('Magnitude (units^2/Hz)') title('PSD of Sine Wave') 
  • 0
    wow, you ca$n$ dig up material, this answer really fits with the previous one as a nice example to try out and get a hands on understanding, thanks!2013-03-03