legendkit.size_legend¶
- class legendkit.size_legend(sizes, *, ax=None, labels=None, array=None, colors=None, fmt=None, func=<function SizeLegend.<lambda>>, num_handle=4, show_at=None, spacing='percentile', handle='circle', handler_kw=None, fill=True, **kwargs)¶
Create legend that represent the size of circle
- Parameters:
- sizesarray-like
The sizes array of all circles on the plot, the unit is point**2, same as
scatter.- ax
Axes The axes to draw the legend
- labelsarray-like
The labels of the legend
- arrayarray-like
The actual data used in plotting, will be used to display labels if labels are not specific
- colorsarray-like
The color of the entry
- fmtstr,
Formatter The format or formatter to use for the labels. When not set, whole-number floats (e.g.
10.0) are displayed without the decimal (e.g.10). Pass"{x:.1f}"to force decimal display.- funcCallable, default: lambda x: x
A function to calculate the labels.
- num_handleint, default: 4
Number of legend entries to show when
show_atis not specified. Ignored whenshow_atis provided explicitly.- show_atarray-like, optional
Explicit percentiles (values in
[0, 1]) at which to show entries. When omitted, nice round values are chosen automatically from the data range usingnum_legendas a hint.- spacing{“percentile”, “uniform”}, default: “percentile”
The spacing of the sizes
- handlestr or sizable handle
You can use any markers in :module:matplotlib.markers
- handler_kwmapping
Use this to control the style of handler
- fillbool, default: True
If not filled, the color will draw on the edge.
- kwargsmapping
Pass to
legendkit.legend()
Examples
>>> from legendkit import size_legend >>> sizes = np.arange(0, 101, 10) >>> _, ax = plt.subplots(figsize=(1, 1.5)); ax.set_axis_off() >>> size_legend(sizes)
Change the looking of legends
>>> array = sizes * 10 >>> _, ax = plt.subplots(figsize=(1, 1.5)); ax.set_axis_off() >>> size_legend(sizes, array=array, ... show_at=[.2, .4, .6, .8, 1.], ... colors=['r', 'r', '.5', '.5', 'g'], ... handler_kw=dict(ec='orange'))