File tree 1 file changed +17
-0
lines changed
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,23 @@ def draw_legend(data, obj):
61
61
if fill_xcolor != "white" : # white is default
62
62
legend_style .append (f"fill={ fill_xcolor } " )
63
63
64
+
65
+ mark_options = []
66
+ handles = obj .legendHandles if hasattr (obj , "legendHandles" ) else obj .legend_handles if hasattr (obj , "legend_handles" ) else None
67
+ if handles :
68
+ all_sizes = set (sz for handle in handles for sz in handle .get_sizes ())
69
+ if len (all_sizes ) > 1 :
70
+ warnings .warn (f"Varying marker sizes in the legend: { all_sizes } . Ignoring all of them." )
71
+ elif all_sizes :
72
+ mark_size = all_sizes .pop ()
73
+ ff = data ["float format" ]
74
+ # setting half size because pgfplots counts the radius/half-width, and sqrt the area
75
+ pgf_size = 0.5 * mark_size ** 0.5
76
+ mark_options .append (f"mark size={ pgf_size :{ff }} " )
77
+
78
+ if mark_options :
79
+ legend_style .append (f"mark options={{{ ', ' .join (mark_options )} }}" )
80
+
64
81
# Get the horizontal alignment
65
82
try :
66
83
alignment = children_alignment [0 ]
You can’t perform that action at this time.
0 commit comments