6
$\begingroup$

This is a question regarding ListLogLogPlot in MMA 10.4. I have tried the solutions suggested in 5369, and they do not appear to work in MMA 10.4, so I would be grateful if this could be considered a new question by the moderators.

Using LogPlot with no tick label formatting, one gets:

LogLogPlot[Log[x!+1], {x, 1, 10^5}, PlotRange -> {{.1, 10^5}, {10^-1, 10^6}}]

enter image description here

Custom labels for the ticks can be added with:

LogLogPlot[Log[x! + 1], {x, .1, 10^5}, PlotRange -> {{.1, 10^5}, 
  {10^-1, 10^6}}, Ticks -> {Table[{10^i, 10^Defer[Evaluate[i]]}, 
  {i, -1, 5}], Table[{10^i, 10^Defer[Evaluate[i]]}, {i, -1, 6}]}]

enter image description here

So far so good. Now with ListLogLogPlot, and no custom tick label formating, we get:

plist = {#, 1. Log[#! + 1]} & /@ {.1, .5, 1, 5, 10, 50, 100, 500, 
     1000, 5000, 10000, 50000, 100000};

ListLogLogPlot[plist, PlotRange -> {{.1, 10^5}, {10^-1, 10^6}}, 
  Joined -> True]

enter image description here

Now try the custom tick labels, identical to those used above with LogLogPlot:

ListLogLogPlot[plist, PlotRange -> {{.1, 10^5}, {10^-1, 10^6}}, 
  Ticks -> {Table[{10^i, 10^Defer[Evaluate[i]]}, {i, -1, 5}], 
  Table[{10^i, 10^Defer[Evaluate[i]]}, {i, -1, 6}]}, Joined -> True]

enter image description here

I have tried text labels in the {value,label} form without any luck. Post 5369 suggests a hack to modify the plot after generation, also no joy.

Thanks!

UPDATE - Looks like this has been fixed in Mathematica 11.0.

ListLogLogPlot[plist, PlotRange -> {{.1, 10^5}, {10^-1, 10^6}}, 
   Ticks -> {Table[{10^i, 10^Defer[Evaluate[i]]}, {i, -1, 5}], 
   Table[{10^i, 10^Defer[Evaluate[i]]}, {i, -1, 6}]}, Joined -> True]

ListLogLogPlot in MMA 11.0

$\endgroup$
6
  • $\begingroup$ I see now that this is a bug in 10.4 regarding ListLogLogPlot rather than an intentional change. Would you instead give me the output of Options[ListLogLogPlot[plist, PlotRange -> {{.1, 10^5}, {10^-1, 10^6}}, Joined -> True], {Ticks, FrameTicks}] on your system? $\endgroup$
    – Mr.Wizard
    Commented Jul 24, 2016 at 22:18
  • $\begingroup$ @Mr.Wizard I can confirm the last plot on 10.4. Requested output is Ticks -> {{{-2.30259, 0.1, {0.01, 0.}, {AbsoluteThickness[0.1]}}... and FrameTicks -> {{{{-2.30259, 0.1, {0.01, 0.}, {AbsoluteThickness[0.1]}} ... $\endgroup$
    – Johu
    Commented Jul 24, 2016 at 22:30
  • $\begingroup$ @Johu Thank you. Do you mind answering a few more questions for me? If so what is the output from Options[ LogLogPlot[Abs[BesselJ[1, x] Sin[x]^2], {x, 1, 10000}, Frame -> True], {Ticks, FrameTicks} ] $\endgroup$
    – Mr.Wizard
    Commented Jul 24, 2016 at 22:33
  • $\begingroup$ @Mr.Wizard {Ticks -> {Charting`ScaledTicks[{Log, Exp}], Charting`ScaledTicks[{Log, Exp}]}, FrameTicks -> {{Charting`ScaledTicks[{Log, Exp}], Charting`ScaledFrameTicks[{Log, Exp}]}, {Charting`ScaledTicks[{Log, Exp}], Charting`ScaledFrameTicks[{Log, Exp}]}}} $\endgroup$
    – Johu
    Commented Jul 24, 2016 at 23:03
  • $\begingroup$ @Johu Thanks, again. FYI you need to use two backticks to open and close a code-block that itself contains backtick. I edited your comment above (scary moderator power, I know) to correct this. Odd that ListLogLogPlot does not follow the convention of all the other plots to use Charting`ScaledTicks and Charting`ScaledFrameTicks as it did in version 10.1.0, and as LogLogPlot still does in 10.4 from your assistance. $\endgroup$
    – Mr.Wizard
    Commented Jul 24, 2016 at 23:06

3 Answers 3

4
$\begingroup$

Here is one way to convert the ticks into the desired format:

ListLogLogPlot[plist, PlotRange -> {{.1, 10^5}, {10^-1, 10^6}}, Joined -> True] /. 
 {v_, t_?NumberQ, l1_, {AbsoluteThickness[0.1]}} :> 
 {v, NumberForm[N@t, NumberFormat -> (Superscript[#2, #3] &), 
  ExponentFunction -> (# &)], l1, {AbsoluteThickness[0.1]}}

Out


With ticks outside and explicitly setting the AxesOrigin to get axes that are more aligned:

f[s_Spacer | s_Superscript] := s

f[n_Real | n_Integer] := Superscript[10, Rationalize@Log10[n]]

ListLogLogPlot[plist, PlotRange -> {{.1, 10^5}, {10^-1, 10^6}}, 
  Joined -> True, AxesOrigin -> {0.1, 0.1}] /. {v_, t_, l1_, l2_} :> {v, f[t], -l1, l2}

Out2

$\endgroup$
5
  • $\begingroup$ Nice solution. I like that the sub-ticks still appear. Is it possible to reverse the tick orientation (towards the outside of the plot) for major and minor ticks with a modification of the script? $\endgroup$
    – GraphMan
    Commented Jul 25, 2016 at 11:28
  • $\begingroup$ @GraphMan Orientation reversion by additional replacement: ListLogLogPlot[plist, PlotRange -> {{.1, 10^5}, {10^-1, 10^6}}, Joined -> True] /. {v_, t_?NumberQ, l1_, {AbsoluteThickness[0.1]}} :> {v, NumberForm[N@t, NumberFormat -> (Superscript[#2, #3] &), ExponentFunction -> (# &)], l1, {AbsoluteThickness[0.1]}} /. {v_, t_, l1_, l2_} :> {v, t, -l1, l2} $\endgroup$
    – Karsten7
    Commented Jul 25, 2016 at 11:52
  • $\begingroup$ This solution does works only on 10.4 due to replacement rule of the form {v_, t_?NumberQ, l1_, {AbsoluteThickness[0.1]}}. Is there a similar soltuion for 10.3? For information Options[ListLogLogPlot[plist, PlotRange -> {{.1, 10^5}, {10^-1, 10^6}}, Joined -> True], {Ticks, FrameTicks}] gives {Ticks -> {Charting`ScaledTicks[{Log, Exp}], Charting`ScaledTicks[{Log, Exp}]}, FrameTicks -> {{Charting`ScaledTicks[{Log, Exp}], Charting`ScaledFrameTicks[{Log, Exp}]}, {Charting`ScaledTicks[{Log, Exp}], Charting`ScaledFrameTicks[{Log, Exp}]}}} $\endgroup$
    – Johu
    Commented Aug 3, 2016 at 13:38
  • $\begingroup$ @Johu Did you see the Update 2015 section in this answer? $\endgroup$
    – Karsten7
    Commented Aug 3, 2016 at 13:50
  • $\begingroup$ ListLogLogPlot[plist, PlotRange -> {{.1, 10^5}, {10^-1, 10^6}}, Joined -> True] /. {v_, t_?NumberQ, l1_, l2_} :> {v, NumberForm[N@t, NumberFormat -> (Superscript[#2, #3] &), ExponentFunction -> (# &)], l1, l2} works in version 9. $\endgroup$
    – Karsten7
    Commented Aug 3, 2016 at 13:50
6
$\begingroup$

I tested on 10.2 and 10.4. I recommend just using the tick labels from some other plot and overlaying the data using Show. With minimal changes to your example I got following proof of principle.

plist = {#, 1. Log[#! + 1]} & /@ {.1, .5, 1, 5, 10, 50, 100, 500, 
    1000, 5000, 10000, 50000, 100000};

Show[{LogLogPlot[0, {x, .1, 10^5}, 
   PlotRange -> {{.1, 10^5}, {10^-1, 10^6}}, 
   Ticks -> {Table[{10^i, 10^Defer[Evaluate[i]]}, {i, -1, 5}], 
     Table[{10^i, 10^Defer[Evaluate[i]]}, {i, -1, 6}]}], 
  ListLogLogPlot[plist, PlotRange -> {{.1, 10^5}, {10^-1, 10^6}}, 
   Joined -> True]}]

enter image description here

$\endgroup$
3
  • $\begingroup$ Very nice!! Thank you!! This is much simpler and more elegant than some of the previous answers to other similar questions. Still, it would be good if this bug was fixed so one did not have to resort to such hacks.... $\endgroup$
    – GraphMan
    Commented Jul 24, 2016 at 22:00
  • 1
    $\begingroup$ If you want to contribute to getting a fix turn your post into a bug report and report to WR. $\endgroup$
    – Johu
    Commented Jul 24, 2016 at 22:01
  • $\begingroup$ Done! Thanks again. $\endgroup$
    – GraphMan
    Commented Jul 24, 2016 at 22:06
2
$\begingroup$

Using custom tick labels still works, but one has to use the logarithmic label position, as this conversion is no longer done automatically for custom tick labels.

ListLogLogPlot[plist, PlotRange -> {{.1, 10^5}, {10^-1, 10^6}}, 
 Ticks -> {Table[{N@Log[10^i], Superscript[10, i]}, {i, -1, 5}], 
           Table[{N@Log[10^i], Superscript[10, i]}, {i, -1, 6}]}, 
 Joined -> True]

Out

$\endgroup$

Your Answer

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

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