ListPolarPlot broken by PlotMarkers & Joined

I think I have found a fix that properly restores the behavior of ListPolarPlot (explanation below):

(* execute once to fix issue *)
ListPlot@{};
If[$VersionNumber==11.2,
  Begin["System`ProtoPlotDump`"],
  Begin["System`ListPlotsDump`"]
];
SubValues@iListPlot = SubValues@iListPlot /. 
  HoldPattern[a : (graphicsoptions = _)] :> 
    (a; AppendTo[method, "OptimizePlotMarkers" -> optimizemarkers]);
End[];

This injects a single line into the definition of iListPlot to restore the proper behavior of ListPolarPlot:

(* the original example *)
ListPolarPlot[Table[1, 10], Joined -> True, PlotMarkers -> Automatic]
(* from https://mathematica.stackexchange.com/questions/19923/listpolarplot-labelling-points-on-the-plot *)
ListPolarPlot[
 Tooltip /@ {0.01422, 0.3425217, 0.30036, 0.013, 0.152, 0.3762, 
   0.122}, Joined -> True, 
 PlotMarkers -> Graphics@Disk[{0, 0}, Scaled[0.025]], 
 Axes -> {True, False}, PolarAxes -> Automatic, 
 PolarGridLines -> {{0.897, 0.897*2, 0.897*3, 0.897*4, 0.897*5, 
    0.897*6, 0.897*7}, {0.1, 0.2, 0.3}}, PolarTicks -> None, 
 AspectRatio -> 1/1, ImageSize -> {300, 300}]

Before

After

Explanation

Note: To see the definitions I'm talking about, load <<GeneralUtilities` and use PrintDefinitions@symbol to get a readable version of the definitions. Also, the symbols have moved from System`ProtoPlotDump` in 11.2 to System`ListPlotsDump` in 11.3 (the below always refers to the 11.3 contexts).

The issue

  • ListPolarPlot internally calls ListPlot (via Graphics`PolarPlotDump`listPolarPlot), and then transforms the result by interpreting the x-Axis as the angle and the y-Axis as the radius (see Graphics`PolarPlotDump`cleanup).
  • Graphics`PolarPlotDump`cleanup only works on GraphicsComplex, so Graphics`PolarPlotDump`listPolarPlot calls ListPlot with "OptimizePlotMarkers"->False, which should prevent a Normalization of the GraphicsComplex to a simple list of coordinates.
  • In 11.2, the code handling "OptimizePlotMarkers" was moved from System`ListPlotsDump`iListPlot to System`ListPlotsDump`postProcessLayout, but the option is never properly forwarded to that function.
  • This causes the GraphicsComplex to be Normalized, which in turn causes Graphics`PolarPlotDump`cleanup to fail.

The fix

  • Since System`ListPlotsDump`postProcessLayout reads out the method parameter to determine the value of "OptimizePlotMarkers", we simply need to add the setting to that list to forward it.
  • We have to do it after graphicsoptions is built, since System`ListPlotsDump`renderLayoutProcess silently crashes the kernel if the Method option contains the "OptimizePlotMarkers" setting.

As workaround you can use either ListPlot or ListLinePlot

x[r_, t_] = r Cos[t];
y[r_, t_] = r Sin[t];

ListPlot[Table[#[GoldenRatio^θ, θ] & /@ {x, y}, {θ, 0, 
   4 Pi, 0.25}],
 Joined -> True,
 PlotMarkers -> Automatic,
 AspectRatio -> 1.5, 
 AxesLabel -> (#[GoldenRatio^θ, θ] & /@ {x, y})]

enter image description here

ListLinePlot[
 Table[#[GoldenRatio^θ, θ] & /@ {x, y}, {θ, 0, 4 Pi, 
   0.25}],
 PlotMarkers -> Automatic
 , AspectRatio -> 1.5, 
 AxesLabel -> (#[GoldenRatio^θ, θ] & /@ {x, y})]

enter image description here

Tags:

Plotting

Bugs