10
$\begingroup$

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

Start with a simple log-log plot.

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

plot

But when I make a button to show the plot

Button["Print", Print[plot]]

and click on it

badplot

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.

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

2 Answers 2

3
$\begingroup$

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

$\endgroup$
2
$\begingroup$

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 .

$\endgroup$
2
  • $\begingroup$ 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. $\endgroup$ Commented Sep 10, 2016 at 8:07
  • $\begingroup$ @AlexeyPopkov. No, I sent in the report before this thread existed. $\endgroup$
    – m_goldberg
    Commented Sep 10, 2016 at 15:32

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.