6

Bug introduced in 8 or earlier and fixed in 12.0.0


Consider the following code:

Needs["SciDraw`"]
Needs["PolygonPlotMarkers`"]
plotData = {{1, 0}};
markers[size_] := Graphics[{PolygonMarker["Disk", Offset[size]]}];
plotA = ListPlot[plotData, PlotMarkers -> markers[8]];
plot = Figure[FigurePanel[{FigGraphics[plotA]}], CanvasSize -> {3, 2}]

enter image description here

The plotted point is not where it's supposed to be, that is, at {1,0}. In fact, it is shifted by precisely {-0.5,0.5}. Only when exported to pdf (last panel) does the point appear at the right position.

What could be the reason for this behavior?

Note that both SciDraw and PolygonPlotMarkers seem to influence the result. At least I can't reproduce the phenomenon when not using both of those packages. However, independent of what those packages do, what could possibly lead to a different output in these two file formats?

If it matters, I have tested this using version 11.0.1 and version 10.4.1 on 64 bit Linux.

SciDraw is available from here.

PolygonPlotMarkers is available from here.

Alexey Popkov
  • 61,809
  • 7
  • 149
  • 368
Felix
  • 3,871
  • 13
  • 33
  • Note that with PlotMarkers -> None you get huge Points in the final plot. So at least your piece of code with Figure somehow introduces a problem with scale. Please distill your code upto a minimal working example for reproducing the problem. Your current example is overcomplicated. – Alexey Popkov Feb 16 '17 at 07:27
  • @AlexeyPopkov True, it's not a trivial example, but unfortunately I every single line seems to matter to reproduce the effect. I really don't know how to make it more simple. – Felix Feb 16 '17 at 15:41
  • Besides an actual answer I would also appreciate any comments on how to improve the question or how to isolate the problem. – Felix Feb 26 '17 at 04:38
  • Related: http://mathematica.stackexchange.com/q/138926/280 – Alexey Popkov Mar 01 '17 at 16:19
  • @AlexeyPopkov That is interesting. Do your PolygonPlotMarkers scale in the same way as ArrowHeads? Also, it seems to me that the ArrowHeads problem is only related to the size of the features, which would explain why I have to use such a small size for the plot markers. But I don't yet see how it relates to position. Do you? – Felix Mar 01 '17 at 20:43
  • With Offset size specifications my markers have fixed sizes (you can check the implementation). But (as noticed in the linked answer) applying ScalingTransform converts Offset coordinates into ordinary coordinates what may cause all the strange distortions you notice. – Alexey Popkov Mar 02 '17 at 00:24
  • @AlexeyPopkov That makes sense. Do you think there is a way around this? I tried Scaled[size] instead of Offset[size], which has the same effect. Just providing a number doesn't scale the markers at all, not even in plotA, i.e., without SciDraw. Is there another way to scale these markers to the desired size? – Felix Mar 02 '17 at 00:37
  • I'm not completely sure but this bug may be related too: http://mathematica.stackexchange.com/a/56329/280 (we need to check what point and in what way is specified as fixed in the ScalingTransform). – Alexey Popkov Mar 02 '17 at 00:58
  • On how to improve the quality of the question: reduce the number of markers used and the number of datapoints to only one. If you are able to demonstrate the same problem with only one datapoint, it is the minimal working example. – Alexey Popkov Mar 02 '17 at 01:24
  • @AlexeyPopkov Thanks, that was a good suggestion. Please see the edited question. It is now evident that the shift is exactly 0.5. – Felix Mar 02 '17 at 02:55

1 Answers1

4

This issue has nothing to do with the PolygonPlotMarkers` package and appears with any primitive-based plot marker:

Needs["SciDraw`"]
plotData = {{1, 0}};
plotA = ListPlot[plotData, PlotMarkers -> Graphics[Disk[{0, 0}, Offset[3]]]]
plot = Figure[FigurePanel[{FigGraphics[plotA]}], CanvasSize -> {3, 2}]

output

output

After some digging I distilled the problem to the following:

g[size_] := Graphics[GeometricTransformation[{
     Inset[Graphics[{Blue, Disk[{0, 0}, Offset[7]]}], {1, 0}],
     Inset[Style["\[FilledCircle]", Red, FontSize -> 15], {1, 0}]},
    {{216, 0}, {0, 144}}],
   Frame -> True, PlotRange -> {{0, 216}, {0, 144}}, ImageSize -> size];

g /@ {150, 200, 300, 400}

screenshot

Here is how it looks Exported to PDF:

Export["i.pdf", %] // SystemOpen

screenshot

In the above we have the same affine transformation applied to two Insets: the first contains Graphics, the second contains a glyph. Both Insets have identical second arguments which specify where they will be placed in the enclosing graphics, hence one should expect that their positions will be identical as it takes place without applying GeometricTransformation:

Graphics[{
  Inset[Graphics[{Blue, Disk[{0, 0}, Offset[7]]}], {1, 0}],
  Inset[Style["\[FilledCircle]", Red, FontSize -> 15], {1, 0}]},
 Frame -> True, PlotRange -> {{0, 1}, {0, 1}}]

graphics

So we have faced a bug in rendering of GeometricTransformation by the FrontEnd. I have found two workarounds:

  1. Specify explicit AlignmentPoint for Graphics:

    g[size_] := Graphics[GeometricTransformation[{
         Inset[Graphics[{Blue, Disk[{0, 0}, Offset[6]]}, AlignmentPoint -> {0, 0}], {1, 0}],
         Inset[Style["\[FilledCircle]", Red, FontSize -> 15], {1, 0}]},
        {{216, 0}, {0, 144}}],
       Frame -> True, PlotRange -> {{0, 216}, {0, 144}}, ImageSize -> size];
    
    g /@ {150, 200, 300, 400}
    

    screenshot

  2. Specify explicit third argument for Inset:

    g[size_] := Graphics[GeometricTransformation[{
         Inset[Graphics[{Blue, Disk[{0, 0}, Offset[6]]}], {1, 0}, {0, 0}],
         Inset[Style["\[FilledCircle]", Red, FontSize -> 15], {1, 0}]},
        {{216, 0}, {0, 144}}],
       Frame -> True, PlotRange -> {{0, 216}, {0, 144}}, ImageSize -> size];
    
    g /@ {150, 200, 300, 400}
    

    screenshot

For working with the SciDraw` package the first workaround is appropriate:

Needs["SciDraw`"]
plotData = {{1, 0}};
plotA = ListPlot[plotData, 
   PlotMarkers -> Graphics[{Blue, Disk[{0, 0}, Offset[5]]}, AlignmentPoint -> {0, 0}]];
plot = Figure[FigurePanel[{FigGraphics[plotA]}], CanvasSize -> {3, 2}]

output

I recommend reporting it to the creator of SciDraw` Mark A. Caprio and to Wolfram tech support. Since the usage of primitive-based plot markers is very common, this problem should be taken quite seriously.


UPDATE

It looks like this bug is strongly related to this, and the same workaround works:

Graphics[{GeometricTransformation[{
    Inset[Graphics[{Blue, Disk[{0, 0}, Offset[7]]}], {100, 0}],
    Inset[Style["\[FilledCircle]", Red, FontSize -> 15], {100, 0}]},
   {{216, 0}, {0, 144}}/100]}, Frame -> True, PlotRange -> {{0, 216}, {0, 144}}]

graphics

(I multiplied the second argument of Inset by 100 and divided the transformation matrix by 100).

Alexey Popkov
  • 61,809
  • 7
  • 149
  • 368
  • Wow, thanks so much for tracking down the problem. I will report the problem to both Wolfram tech support and to Caprio. I will post their reply. – Felix Mar 10 '17 at 15:19
  • 1
    The bug has been confirmed by WRI. Let's hope that they fix it. – Felix Mar 14 '17 at 21:47