# Why does Rotate in PlotMarkers behave strangely?

Bug introduced in 9.0 or earlier and persisting through 12.0

While answering Change the inner color of markers I came across a behavior that may be a bug.
I would like to know if there is another explanation.

First a basic example of normal behavior:

ListLinePlot[{Prime~Array~12, Fibonacci~Array~12},
PlotMarkers -> Graphics[{Brown, Rectangle[]}, ImageSize -> 13],
PlotLegends -> Automatic
]


Note that the markers are included in the legend. But now if I Rotate the Rectangle:

ListLinePlot[{Prime~Array~12, Fibonacci~Array~12},
PlotMarkers -> Graphics[{Brown, Rectangle[] ~Rotate~ (Pi/4)}, ImageSize -> 13],
PlotLegends -> Automatic
]


The markers disappear from the legend. They do appear if I Rotate the entire Graphics, however the markers are not scaled as before and they clip:

ListLinePlot[{Prime~Array~12, Fibonacci~Array~12},
PlotMarkers -> Graphics[{Brown, Rectangle[]}, ImageSize -> 13] ~Rotate~ (Pi/4),
PlotLegends -> Automatic
]


1. Is use of Rotate in plot markers simply unsupported or is this a bug?

2. Is there a way to use rotated primitives for markers and not break the legend?

One workaround is to use GeometricTransformation instead of Rotate. By specifying coordinates in the Offset form we can achieve consistent size of markers on the plot and in the legend. The cropping of the markers in the legend can be avoided by increasing their sizes as MinHsuan Peng suggests:

ListLinePlot[{Prime~Array~12, Fibonacci~Array~12},
PlotMarkers ->
Graphics[{Brown,
GeometricTransformation[
Rectangle[Offset[{-5, -5}], Offset[{5, 5}]],
RotationTransform[Pi/4]]}],
PlotLegends -> LineLegend[Automatic, LegendMarkerSize -> {40, 15}]]


Comparison of the InputForms of the plot generated with Rotate and with GeometricTransformation reveals that another workaround is to specify explicitly the rotation point:

ListLinePlot[{Prime~Array~12, Fibonacci~Array~12},
PlotMarkers -> Graphics[{Brown, Rotate[Rectangle[], (Pi/4), {0, 0}]}, ImageSize -> 13],
PlotLegends -> Automatic]


This workaround proves that Rotate in PlotMarkers is supported but has a bug when used without explicit rotation point as the third argument. It is interesting that specifying Rectangle coordinates in the Offset form reveals even more strange bugs:

ListLinePlot[{Prime~Array~12, Fibonacci~Array~12},
PlotMarkers ->
Graphics[{Brown,
Rectangle[Offset[{-5, -5}], Offset[{5, 5}]]~Rotate~(Pi/4)},
ImageSize -> 10], PlotLegends -> Automatic]


But with explicit rotation point it is OK:

ListLinePlot[{Prime~Array~12, Fibonacci~Array~12},
PlotMarkers ->
Graphics[{Brown, Rotate[Rectangle[Offset[{-5, -5}], Offset[{5, 5}]], (Pi/4), {0, 0}]},
ImageSize -> 13], PlotLegends -> LineLegend[Automatic, LegendMarkerSize -> {40, 15}]]


A workaround to question 2 is to increase legend marker size:

LineLegend[Automatic, LegendMarkerSize -> {40, 20}]