# LegendMarkerSize doesn't work here?

I'm trying to change the marker size on the legend of a figure.

Simply:

x = {1, 5, 10};

y = {1, 7, 31};

xy = Transpose@{x , y};

ListLogLogPlot[xy, PlotLegends -> {"hey", LegendMarkerSize -> 0.6}]


And, no matter which LegendMarkerSize I choose, I always get the same marker size in the legend.

Any idea on how to really change the size of the marker inside the legend?

Thank you so much.

• You have 2 undetermined parameters: niterations, data and numberplot. This way it is impossible to repeat your results. We can start thinking on your question as soon as we can repeat and then play with your code. A good idea would be to add the definition of the missing values to your code. – Alexei Boulbitch Jul 2 '18 at 10:56
• Well, in fact it as only an example. I edit my question to simpler case where the same happens – Guillermo Martínez Somonte Jul 2 '18 at 11:27
• You're using the wrong syntax to specify options for the legend. See @AlexeiBoulbitch's answer for the proper way – Lukas Lang Jul 2 '18 at 13:55
• Did any of the answers satisfied your need? There are things to do after your question is answered. It's a good idea to stay vigilant for some time, better approaches may come later improving over previous replies. Experienced users may point alternatives, caveats or limitations. New users should test answers before voting and wait 24 hours before accepting the best one. One weeks is enough wait. Participation is essential for the site, please do your part. – rhermans Jul 9 '18 at 22:36

For the case in OP (where the PlotMarkers option does not appear in the main plot), LegendMarkerSize option works as expected if PointLegend is used with its first argument set to the PlotStyle of the main plot:

ListLogLogPlot[{xy ,{1, 2} # & /@ xy},
PlotLegends -> PointLegend[97, {"hey", "hey 2"}, LegendMarkerSize -> 40]]


ListLogLogPlot[{xy , {1, 2} # & /@ xy},
PlotStyle -> (ps = "Rainbow"),
PlotLegends -> PointLegend[ps, {"hey", "hey 2"}, LegendMarkerSize -> 60]]


Specifying Disk markers corrects this:

ListLogLogPlot[{xy, 2 xy}
, PlotMarkers -> {Graphics@{Disk[]}, .05}
, PlotLegends -> PointLegend[{"hey", "there"}, LegendMarkerSize -> 70]
]


Note that {Disk[]} is needed rather than simply Disk[] because of How to make PlotMarkers constructed from Graphics track plot style?

Try this:

Manipulate[
ListLogLogPlot[xy, PlotMarkers -> Automatic,
PlotLegends -> PointLegend[{"hey"}, LegendMarkerSize -> sz]], {sz,
0.5, 50}]


Generally, it seems that some problem causes the log-log character of the plot. Try to increase the marker size well beyond 50.

Have fun!

• The behavior of this is weird though, and I don't think it has to do with the log plot. Try it with simple ListPlot: MMA appears to make space for a larger legend marker, but then the marker itself is always drawn at the same size. – MarcoB Jul 2 '18 at 13:59
• @MarcoB that's because the marker is a textual form with a font-size. So, there is an effective upper limit to the marker size. – rcollyer Jul 2 '18 at 14:36

A combination of PointSize and LegendMarkerSize appear to be necessary to overcome the problem mentioned by @rcollyer in comments, i.e. the fact that, since the marker is a textual form with a font-size, there is an effective upper limit to the marker size.

Here is a helper function that takes a plot with a PointLegend and replaces the appropriate values within the plot with new user-defined ones to enlarge the legend markers:

ClearAll[enlargeLegendMarker]
enlargeLegendMarker[plotobject_, newsize_] :=
ReplaceAll[
plotobject,
Legended[plot_,
Placed[
legend_,
options__]
] :>
Legended[plot,
Placed[
Append[legend /. PointSize[_] -> PointSize[newsize], LegendMarkerSize -> 350 newsize],
options
]
]
]


The function takes a plot and a new fractional marker size as arguments. Note that an appropriate LegendMarkerSize must be calculated depending on the PointSize to have enough room for each marker at size. This was done by trial and error. A value of $350\times$ the new fractional size seems to work well.

Some definitions:

xy = {{1, 1}, {5, 7}, {10, 31}};
plot = ListLogLogPlot[{xy, 2 xy}, PlotLegends -> {"hey", "you"}];


And some usage examples:

{Style[#, 20], enlargeLegendMarker[plot, #]} & /@ {0.02, 0.05, 0.1, 0.3} // TableForm


Here is an alternative way to do it.

xy = {{1, 1}, {5, 7}, {10, 31}};
imgSize = 10;
legend = Grid[ Transpose@{Graphics[{ColorData[97, #], Disk[]},
ImageSize -> imgSize] & /@ Range@2, {"hey", "you"}}];

ListLogLogPlot[{xy, 2 xy}, PlotLegends -> Placed[legend, Right]]


imgSize = 20;