Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Using PlotLegends with a PlotStyle containing (for instance) PointSize[0.02] creates a legend that does not match the plot.

ListPlot[Table[RandomReal[NormalDistribution[], {20, 2}], {2}],
 PlotLegends -> {"a", "b"}, PlotStyle -> PointSize[0.02]]

enter image description here

How can I get a sensible legend when using a number with PointSize? Solutions involving named sizes (like PointSize[Medium]) are inadmissible unless they somehow create points that have a constant size relative to the plot size.

share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

This problem often occurs in plotting and graphics because of the use of Foo instead of AbsoluteFoo for the directives. The former uses sizes relative to the plot size, whereas the latter, as the name suggests, uses absolute sizes.

In the built-in plot legends in version 9, the plot and the legend are actually two separate objects which are just combined, hence PointSize uses the figure size of each of those to compute what 0.02 means. All you need to do is to change it to AbsolutePointSize to keep it consistent between the two. Of course, the argument will also change and AbsolutePointSize[7] looks close enough to what you were gunning for.

share|improve this answer
    
Thanks for your answer. I'm disappointed because this kind of trial end error is what I had hoped would be eliminated by the new legends capabilities. I'd say it's not mature yet. –  ArgentoSapiens Jan 10 '13 at 18:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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