7
$\begingroup$

Why does the PlotRange option in

list=Table[{x,Exp[Sqrt[x]]},{x,0,25}];
ListLogLogPlot[list,PlotRange->{0,10},Joined->True]

not work although there is no error-output? The same holds for ListLogLogPlot.

$\endgroup$
0

2 Answers 2

11
$\begingroup$

This is because you gave 0 as the lower limit and $\log (0)=-\infty$. If you look at the implementation of ListLogLogPlot, you'll see that somewhere along the line, the limits are converted to {N@Log@min, N@Log@max} and then plotted with ListPlot and the tick labels are tidied up. This is the specific line in the implementation:

logYPlotRange[{min_?Positive, max_?Positive}, r_] :=  N[{Log[min], Log[max]}]

So an extreme plot range will automatically be converted to something more "reasonable" that displays the plot. However, I do agree that a warning should be included. For instance, if you use -∞ as a plot range in Plot, you get the following warning:

Plot::prng: Value of option PlotRange -> {-∞,1} is not All, Full, Automatic, a positive machine number, or an appropriate list of range specifications. >>

If you want to set the limits for the axes from within PlotRange, then avoid 0. For example:

list = Table[{x, Exp[Sqrt[x]]}, {x, 0, 25}];
ListLogLogPlot[list, Joined -> True, PlotRange -> {{1, 10}, {1, 50}}]

$\endgroup$
1
  • 1
    $\begingroup$ If you look at the implementation of ListLogLogPlot. Where did you take a look at the implementation? Is that possible? $\endgroup$
    – a06e
    Nov 8, 2017 at 17:15
3
$\begingroup$

I've seen problems with this before but can't find the reference right now. So here is a solution:

list = Table[{x, Exp[Sqrt[x]]}, {x, 0, 25}];
ListLogLogPlot[list, Joined -> True, PlotRange -> {1, 10}]

or

list = Table[{x, Exp[Sqrt[x]]}, {x, 0, 25}];
ListLogLogPlot[list, Joined -> True, PlotRange -> {All, {1, 10}}]

loglogplot

The problem of course could be called a bug, but in some sense it's also understandable that the plot range specification breaks when you put in a value of 0 for the argument on the x or y axis in a log-log plot. After all, the logarithm isn't defined there. It would be better if the function could recognize this and warn you, instead of ignoring the input altogether.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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