# Labeled destroys the log scales in “log” plots when notebook is re-opened

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

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

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"]

ListLogLogPlot[Range[20]^3]
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"]
Labeled[ListPlot[Fibonacci[Range[50]],
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.
• 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. – Alexey Popkov Apr 9 '16 at 12:18
• 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. – Alexey Popkov Apr 9 '16 at 12:28
• 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[{ChartingScaledTicks[{Log, Exp}], ChartingScaledTicks[{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. – Alexey Popkov Apr 9 '16 at 12:39
• @AlexeyPopkov It seems the bug has been fixed since v11.1.0 (I am on OSX). Can you confirm ? – SquareOne May 12 '17 at 19:29
• 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. – Alexey Popkov May 13 '17 at 2:29

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[{ChartingScaledTicks[{Log, Exp}],
ChartingScaledTicks[{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]}},


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.

• 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. – SquareOne Apr 10 '16 at 9:49
• 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. – Alexey Popkov Apr 10 '16 at 11:45
• @AlexeyPopkov that is great. Could explain how does that first trick (With[...) happen, I am not sure I fully understand it. – Basheer Algohi Apr 11 '16 at 3:00
• @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"]}. – Alexey Popkov Apr 11 '16 at 3:08
• Aha, I got it. It is more clear when you look at FullForm of the plot. Thanks – Basheer Algohi Apr 11 '16 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"]

• 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. – SquareOne Apr 7 '16 at 15:46