# Strange output when a log-log plot is displayed by means of a button

Bug introduced in 8 or earlier and persists through 11.0.0

I have encountered some strange behavior on the part of the front-end.

\$Version


"10.4.1 for Mac OS X x86 (64-bit) (April 11, 2016)"

plot = LogLogPlot[x^10, {x, 1, 100}, ImageSize -> 450]


But when I make a button to show the plot

Button["Print", Print[plot]]


and click on it

The tick labels are wrong. However, it gets weirder. When I copy the above plot and paste it back into the notebook, the pasted version is correct. This convinces me that this is front-end misbehavior.

Why does the front-end render the plot ticks incorrectly if and only if the plot is rendered by calling Print[plot] in a button's action? (I have confirmed that it does not happen when I evaluate Print[plot] at top-level.)

Also, can other's confirm this behavior persists in V11 (which I don't have)? I think this is a front-end bug, but it might be corrected in V11.

• Workaround: add Method->"Queued" to Button, also the ticks appear on resizing. – rcollyer Sep 7 '16 at 2:53
• @rcollyer. Thanks, that works. Didn't think trying (but probably should have) because the rendering time didn't seem long enough to require queueing. – m_goldberg Sep 7 '16 at 3:00
• I confirm your observations on Mma 11, Win7. – Alexei Boulbitch Sep 7 '16 at 6:47

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, ChartingScaledTicks[{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.

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 .

• Thank you for reporting. Have you included a link to this thread in the report? I think that information collected here could help the developers. – Alexey Popkov Sep 10 '16 at 8:07
• @AlexeyPopkov. No, I sent in the report before this thread existed. – m_goldberg Sep 10 '16 at 15:32