6
$\begingroup$

Bug introduced in 8 or earlier and persisting through 11.2.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.

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Alexey Popkov Feb 16 '17 at 7:27
  • $\begingroup$ @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. $\endgroup$ – Felix Feb 16 '17 at 15:41
  • $\begingroup$ Besides an actual answer I would also appreciate any comments on how to improve the question or how to isolate the problem. $\endgroup$ – Felix Feb 26 '17 at 4:38
  • $\begingroup$ Related: mathematica.stackexchange.com/q/138926/280 $\endgroup$ – Alexey Popkov Mar 1 '17 at 16:19
  • $\begingroup$ @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? $\endgroup$ – Felix Mar 1 '17 at 20:43
4
$\begingroup$

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

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Felix Mar 10 '17 at 15:19
  • 1
    $\begingroup$ The bug has been confirmed by WRI. Let's hope that they fix it. $\endgroup$ – Felix Mar 14 '17 at 21:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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