3
$\begingroup$

Bug introduced in 11.2 and persists through 12.2, case 4331202

I'm trying to see some plots based on data from a remote cluster as it runs various Mathematica 11.3/12 scripts, so I want to use the JavaGraphics` package to render plots that I can in turn X11 forward to my computer. The X11 forwarding is definitely working, as I can Plot and ListPlot3d just fine and get nice plots. However, when I try to ListPlot, it fails. I'm able to reproduce this same behavior in my local Mathematica 12 Notebook. Here's how:

<<"JavaGraphics`"
Plot[Sinc[x],{x,0,20}]
Pause[5];
ListPlot3D[Table[Mod[x,y],{x,0,20},{y,0,20}]]
Pause[5];
ListPlot[Table[Prime[n],{n,1,20}]]

But meanwhile, when I go back into the internet sands of time, I see evidence of it working at some point. Somewhat infuriatingly, ListPlot is the function I need, and I can't see how I could replace it for making a scatter plot.

As a potential foray into figuring this out, I noticed that I get the same non-functionality with the option DisplayFunction->CreateDialog.

Plot[Sinc[x],{x,0,20},DisplayFunction->CreateDialog]
Pause[5];
ListPlot3D[Table[Mod[x,y],{x,0,20},{y,0,20}],DisplayFunction->CreateDialog]
Pause[5];
ListPlot[Table[Prime[n],{n,1,20}],DisplayFunction->CreateDialog]

I've confirmed both of these bugs over multiple Mathematica installations on multiple devices running both 11.3 and 12.

Does anyone have any experience with this, or any hunches as to why this isn't working?

$\endgroup$
1
  • $\begingroup$ This looks like another one of those things that got broken in 11.2 when they moved stuff around in the internals of ListPlot, I would report it as a bug to WRI. You can then also add the case id you get when submitting to the top of the question. I'll try to post a manual fix later today. $\endgroup$
    – Lukas Lang
    Oct 12, 2019 at 16:20

1 Answer 1

3
$\begingroup$

As noted in the comments, this bug appears to have been introduced in version 11.2, when they moved a lot of the plot post-processing into System`ListPlotsDump`postProcessLayout. The issue occurs because they temporarily set DisplayFunction->Identity (to prevent multiple applications of the DisplayFunction), and then the wrong DisplayFunction setting is forwarded to `postProcessLayout. The code below fixes this issue by prepending the correct setting to the relevant list of options:

ListPlot[{}];
Begin[If[$VersionNumber >= 11.3, "System`ListPlotsDump`", 
   "System`ProtoPlotDump`"]];
With[{sym = If[$VersionNumber >= 12.1, `preProcessLayout, `iListPlot]},
  SubValues[sym] = SubValues[sym] /. 
    HoldPattern[lhs : _["PreProcessedOptions"] = `opts] :>
      (lhs = Prepend[`opts,
        DisplayFunction -> OptionValue[{`fn, `iListPlot}, `o, DisplayFunction]
      ])
  ];
End[];

Update

They seem to have moved stuff around again in 12.1, now the line to be patched is in System`ListPlotsDump`preProcessLayout. The variable displayfunction also doesn't exist anymore, so we have to extract it ourselves. I have patched the code above to account for this.

$\endgroup$
5
  • $\begingroup$ Thank you for this response! I've tested it and on my local machine this resolves ListPlot not rendering properly with either CreateDialog or with JavaGraphics`. However, when I tried to run this on a remote Mathematica kernel (either in the mathematica shell or as a math -script) ListPlot continues to not be able to plot something that X11 forwards. Other plotting functions continue to work, but not ListPlot. $\endgroup$
    – jeeves6626
    Oct 13, 2019 at 19:24
  • $\begingroup$ @jeeves6626 That's strange… Unfortunately, I do not have a recent enough version of Mathematica set up on a unix machine, so I can't easily test this. Can you evaluate SubValues@System`ListPlotsDump`iListPlot (version 11.2) or System`ProtoPlotDump`iListPlot (version >11.2) in the remote kernel and post the result somewhere like pastebin? $\endgroup$
    – Lukas Lang
    Oct 13, 2019 at 22:09
  • $\begingroup$ On a 12.0.0 shell, I evaluated the above redefinition both directly in the shell and as part of a package, and I checked whether SubValues@ would come out to something either in the shell or as part of a script, and I got only that it was completely empty: {}. I also ran this in my local 12.0.0 notebook, with the same results. $\endgroup$
    – jeeves6626
    Oct 14, 2019 at 16:37
  • $\begingroup$ This work-around seems to be broken in v12.2: mathematica.stackexchange.com/q/246668/1871 Any idea? $\endgroup$
    – xzczd
    Jun 7, 2021 at 7:45
  • $\begingroup$ @xzczd Thanks for notifying me about this! Should be fixed now $\endgroup$
    – Lukas Lang
    Jun 7, 2021 at 8:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.