0
$\begingroup$

I am trying to use PolygonMarkers as markers for a ListPlot and its legend. However, for some reason, the legend markers get cut off and are not shown fully. Here is an example:

(* creating the marker *) 
tps = Show[
  ResourceFunction["PolygonMarker"][
   "ThreePointedStar", {Offset[10], 3}, {EdgeForm[Black], 
    FaceForm[White]}],
  ResourceFunction["PolygonMarker"][
   "ThreePointedStar", {Offset[5], 3}, {EdgeForm[White], 
    FaceForm[Red]}]
  ]

(* a simple ListPlot example *) 

ListPlot[
  Table[{i, 2 i}, {i, 1, 5}],
 Joined -> False, FrameLabel -> {"a", "b"},
 PlotLabel -> "F",
 PlotLegends -> 
  Placed[LineLegend[{"T"}], {Top, Right}],
 PlotMarkers -> Style[tps, Magnification -> 2],
 PlotRange -> Automatic,
 ImagePadding -> All,
 ImageSize -> Medium]

In this case, the legend marker is cut off. The only solution that I found is to set LegendMarkerSize to around 40. However, this does not seem like an ideal workaround; I would expect the Legend command automatically take care of the size of the markers, so that it would work for different markers with different sizes that I want to use.

Is there a way to make this automatic adjustment?

$\endgroup$

1 Answer 1

2
$\begingroup$

First of all, using PlotRangeClipping -> False prevents the clipping of the plotmarker in the plot itself.

Then the size of a PlotMarker, and how much space has to be reserved for it in a legend, is determined by the option Offset or Scaled. Just putting in Offset[50] as an option for the PlotMarker does the trick:

ListPlot[Table[{i, 2 i}, {i, 1, 5}], Joined -> False, FrameLabel -> {"a", "b"},
PlotLabel -> "F", PlotLegends -> Placed[LineLegend[{"T"}], {Top, Right}],
PlotMarkers -> {Style[tps, Magnification -> 2], Offset[50]}, PlotRange ->
Automatic, ImagePadding -> All, ImageSize -> Medium, PlotRangeClipping ->
False]
$\endgroup$

Your Answer

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

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