Bug introduced in 10 or earlier and fixed in 11.1

While testing this pdf export bug caused by Labeled, I noticed that this function also destroys the log scales in all "log" plots when you reopen the notebook in which the plots were created.

The problem not only concerns the plots generated by the different *Log* functions but also those obtained by setting the option ScalingFunctions to the "Log" mode (see examples below):

For example when you execute:

Labeled[LogLogPlot[x, {x, 10^-5, 1}], "Test"] 

it displays correctly

enter image description here

but once you save/close/reopen the notebook, this previous plot becomes:

enter image description here

Here are some other examples showing the same wrong behavior (for me with MMA v10.3.1, OSX):

LogLogPlot[x, {x, 10^-5, 1}]
Labeled[LogLogPlot[x, {x, 10^-5, 1}], "LogLogPlot"]

LogLinearPlot[Tanh[x], {x, 1, 100}]
Labeled[LogLinearPlot[Tanh[x], {x, 1, 100}], "LogLinearPlot"]

LogPlot[x^x, {x, 1, 5}]
Labeled[LogPlot[x^x, {x, 1, 5}], "LogPlot"]

ListLogPlot[Table[PartitionsQ[n], {n, 50}]]
Labeled[ListLogPlot[Table[PartitionsQ[n], {n, 50}]], "ListLogPlot"]

Labeled[ListLogLogPlot[Range[20]^3], "ListLogLogPlot"]

Plot[Exp[x], {x, 1, 10}, ScalingFunctions -> "Log"]
Labeled[Plot[Exp[x], {x, 1, 10}, ScalingFunctions -> "Log"], "Plot"]

ListPlot[Fibonacci[Range[50]], ScalingFunctions -> "Log"]
  ScalingFunctions -> "Log"], "ListPlot"]

gh = Histogram[
  VertexDegree[RandomGraph[BarabasiAlbertGraphDistribution[10^4, 3]]],
   ColorFunction -> "Rainbow", ScalingFunctions -> {"Log", "Log"}, 
  PlotRange -> All]
Labeled[gh, "Histogram"]

In v10.4.0 however, the problem does not occur anymore for ListLogPlot, ListLogLogPlot and ListPlot. The problem was probably noticed while adding Labeled as a new possible wrapper for the datas (see the corresponding documentations), maybe involving a redesign of these functions ...

The only workaround (as originally proposed by @Algohi) seem to be to wrap the whole Labeled expression with Dynamic.

I also notice that:

  • you can copy/paste the "wrong" plot, to get back the original correct plot.
  • you can wrap the plot in GraphicsGrid (GraphicsRow, ...) to prevent the log scale to be destroyed. However this is not a very useful workaround as the final plot has extra margins which I was not able to get rid of.
  • 2
    $\begingroup$ It's a bug indeed. The key difference between ListLogLogPlot and LogLogPlot (in version 10.4) is that ListLogLogPlot's output contains explicit Ticks specification while LogLogPlot contains functional (Dynamic) specification. Added the bugs tag. $\endgroup$ Apr 9, 2016 at 12:18
  • 2
    $\begingroup$ It is interesting that if we copy the InputForm of LogLogPlot wrapped by Labeled from Mathematica 10.4 to 8.0.4 and then evaluate and save, the generated plot looks OK when opened with version 10.4. But if we evaluate the code in version 10.4 again and save, the bug appears again after reopening both with version 8.0.4 and 10.4. So the underlying bug seems to be present already in version 8.0.4 but doesn't manifestate due to some difference in the corresponding BoxData. $\endgroup$ Apr 9, 2016 at 12:28
  • 1
    $\begingroup$ The key difference in the BoxData between version 8.0.4 and 10.4 is that in version 8.0.4 it contains cached explicit Ticks specification in the form Ticks -> FrontEndValueCache[{Charting`ScaledTicks[{Log, Exp}], Charting`ScaledTicks[{Log, Exp}]}, {{{-13.122363377404328`, FormBox[InterpretationBox[StyleBox[ GraphicsBox[{}, ImageSize -> {0., 0.}, BaselinePosition -> Baseline], "CacheGraphics" -> False], Spacer[{0., 0.}]], TraditionalForm], {0.005, 0.}, { Thickness[0.001]}}, <...> while in version 10.4 it doesn't. $\endgroup$ Apr 9, 2016 at 12:39
  • $\begingroup$ @AlexeyPopkov It seems the bug has been fixed since v11.1.0 (I am on OSX). Can you confirm ? $\endgroup$
    – SquareOne
    May 12, 2017 at 19:29
  • $\begingroup$ I confirm that the problem is absent in version 11.1.1 on Windows 7 x64. In version 11.0.1 on the same machine it is present, so the bug seems to be fixed in version 11.1. $\endgroup$ May 13, 2017 at 2:29

2 Answers 2


The workaround suggested by Algohi works but it leads to reevaluation of the entire LogLogPlot each time you open a Notebook. The following workaround avoids this:

With[{g = Labeled[LogLogPlot[x, {x, 10^-5, 1}], "Test"]}, Dynamic@g]

Another workaround is to place this Graphics as Inset inside of another Graphics object:

pl = LogLogPlot[x, {x, 10^-5, 1}];
Labeled[Graphics[{Inset[pl, Center, Center, Scaled[1]]}, 
  Options[pl, {AspectRatio, ImageSize}]], "LogLogPlot"]

(the correct ticks will be generated only after you click the Enable Dynamics button after opening the Notebook).

The essence of the bug is that FrontEnd does not update functional (i.e. Dynamic) Ticks specification when Graphics is enclosed by Labeled. The bug doesn't reveal itself in older Mathematica versions seemingly because in those versions the BoxData of the output Cell in the Notebook contains cached explicit Ticks specification produced during first-time rendering of the output by the FrontEnd (the following is a truncated version of that specification generated by version 8.0.4):

Ticks -> FrontEndValueCache[{Charting`ScaledTicks[{Log, Exp}], 
    Charting`ScaledTicks[{Log, Exp}]}, {{{-13.122363377404328`, 
       StyleBox[GraphicsBox[{}, ImageSize -> {0., 0.}, BaselinePosition -> Baseline], 
        "CacheGraphics" -> False], Spacer[{0., 0.}]], TraditionalForm], {0.005, 
      0.}, {Thickness[0.001]}}, 

When Graphics is wrapped by Labeled Mathematica 10 (as opposed to version 8.0.4) doesn't generate this cache. And it is still ignoring functional Ticks specification when Graphics is wrapped by Labeled.

  • 1
    $\begingroup$ I actually was digging exactly in the same direction at the time you posted your first comment yesterday ;) Also, I don't get what you exactly mean in the last sentence. What I observe is that Labeled prevents the ticks cache (FrontEndValueCache) to be generated (as it is normally the case for all plots without Labeled). In v10.4, they seem to have redesigned some functions (see my updated post), and the cache isn't generated anymore but ticks are explicitly given. $\endgroup$
    – SquareOne
    Apr 10, 2016 at 9:49
  • 1
    $\begingroup$ Thank you for the comment and update in the question. I have corrected my answer and added another workaround based on you findings with GraphicsGrid. $\endgroup$ Apr 10, 2016 at 11:45
  • $\begingroup$ @AlexeyPopkov that is great. Could explain how does that first trick (With[...) happen, I am not sure I fully understand it. $\endgroup$ Apr 11, 2016 at 3:00
  • $\begingroup$ @Algohi The trick is simply to pre-evaluate LogLogPlot and then pass the result to Dynamic. So Dynamic won't evaluate LogLogPlot because it contains the final result of the evaluation. The same can be done shorter as Dynamic @@ {Labeled[LogLogPlot[x, {x, 10^-5, 1}], "Test"]}. $\endgroup$ Apr 11, 2016 at 3:08
  • $\begingroup$ Aha, I got it. It is more clear when you look at FullForm of the plot. Thanks $\endgroup$ Apr 11, 2016 at 3:16

LogLogPlot plots contain a dynamic objects which when you open the notebook, the security of Mathematica prevents the dynamic objects from being updated. Check this

What you can do is wrap your plot with dynamic and when opened again and when you click Enable Dynamic, you will get the correct plot.

Dynamic@Labeled[LogLogPlot[x, {x, 10^-5, 1}], "Test"]
  • 2
    $\begingroup$ Your workaround works but do you have so more detailed explanation ? If LogLogPlot is used without Labeled no problem then. So Labeled prevents this dynamic updating ? Anyway, this is not the expected behavior. $\endgroup$
    – SquareOne
    Apr 7, 2016 at 15:46

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.