Strange output when a log-log plot is displayed by means of a button
I confirm this behavior with version 11.0.0 on Windows 7 x64. With a slight modification of the original code I was able to reproduce this behavior also with version 8.0.4:
plot = Show[LogPlot[x^10, {x, 1, 10}],
Ticks -> {Automatic, Charting`ScaledTicks[{Log, Exp}]}]
Button["Print", Print[plot]]
(the key is that Ticks
are specified as a function in the final Graphics
).
By the essence FrontEnd simply "forgets" that Dynamic
(functional) Ticks
must be updated when displaying Graphics
on-screen for the first time.
I think that this bug is strongly related. The only difference is that in that case FrontEnd "forgets" that functional Ticks
must be updated when displaying Graphics
for the first time after reopening saved Notebook.
The workarounds from the linked thread work:
Button["Print", Print[Dynamic@plot];]
Button["Print",
Print@Graphics[{Inset[plot, Center, Center, Scaled[1]]},
Options[plot, {AspectRatio, ImageSize}]]]
For the case of Button
there are additional workarounds and the shortest is to use Paste
instead of Print
:
Button["Print", Paste[plot]]
CellPrint
works too:
Button["Print", CellPrint[ExpressionCell[plot, "Output"]]]
The workaround suggested by rcollyer also works:
Button["Print", Print[plot], Method -> "Queued"]
but I see no reason why the original code shouldn't work with the default Method -> "Preemptive"
.
I reported the issue raised in my question to Wolfram Research technical support. I received a reply quite promptly. Without all the boiler plate, it boils down to:
I was able to reproduce the issue, and consequently, I filed a report with our development team raising the issue
Rather short and uninformative, but at least it would appear that the tech support person who processed my report thinks it needs the attention of the developers. On that basis, I am tagging the question with bugs.