Skip to content

Commit dd386ce

Browse files
committed
DOC: Improve legend rcParams descriptions
1 parent 1849379 commit dd386ce

2 files changed

Lines changed: 35 additions & 27 deletions

File tree

‎lib/matplotlib/legend.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def _update_bbox_to_anchor(self, loc_in_canvas):
164164
same height, set to ``[0.5]``.
165165
166166
markerscale : float, default: :rc:`legend.markerscale`
167-
The relative size of legend markers compared to the originally drawn ones.
167+
The relative size of legend markers compared to the data markers.
168168
169169
markerfirst : bool, default: True
170170
If *True*, legend marker is placed to the left of the legend label.
@@ -237,10 +237,11 @@ def _update_bbox_to_anchor(self, loc_in_canvas):
237237
are aligned as a single block, so that markers always lined up.
238238
239239
borderpad : float, default: :rc:`legend.borderpad`
240-
The fractional whitespace inside the legend border, in font-size units.
240+
The spacing between legend content and the border of the legend box, in
241+
font-size units.
241242
242243
labelspacing : float, default: :rc:`legend.labelspacing`
243-
The vertical space between the legend entries, in font-size units.
244+
The vertical spacing between the legend entries, in font-size units.
244245
245246
handlelength : float, default: :rc:`legend.handlelength`
246247
The length of the legend handles, in font-size units.

‎lib/matplotlib/rcsetup.py‎

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2556,99 +2556,104 @@ class _Subsection:
25562556
validator=validate_float_or_None,
25572557
description="If None defaults to grid.alpha"
25582558
),
2559-
_Section("Legend"),
2559+
_Section(
2560+
"Legend",
2561+
description="Default legend properties. All entries define defaults for "
2562+
"parameters of `.Legend` / `.Axes.legend` / `.Figure.legend`."
2563+
),
25602564
_Param(
25612565
"legend.loc",
25622566
default="best",
25632567
type=str | int | tuple[float, float],
25642568
validator=_validate_legend_loc,
2565-
description="The legend location. See the *loc* parameter in `.Axes.legend`."
2569+
description="Legend location. See the *loc* parameter in `.Axes.legend`."
25662570
),
25672571
_Param(
25682572
"legend.frameon",
25692573
default=True,
25702574
type=bool,
25712575
validator=validate_bool,
2572-
description="if True, draw the legend on a background patch"
2576+
description="Whether to draw the legend on a background patch."
25732577
),
25742578
_Param(
25752579
"legend.framealpha",
25762580
default=0.8,
25772581
type=float | None,
25782582
validator=validate_float_or_None,
2579-
description="legend patch transparency"
2583+
description="Transparency of the legend background patch."
25802584
),
25812585
_Param(
25822586
"legend.facecolor",
25832587
default="inherit",
25842588
type=':mpltype:`color` or "inherit"',
25852589
validator=validate_color_or_inherit,
2586-
description="inherit from axes.facecolor; or color spec"
2590+
description="Color of the legend background. 'inherit' uses 'axes.facecolor'."
25872591
),
25882592
_Param(
25892593
"legend.edgecolor",
25902594
default="0.8",
25912595
type=':mpltype:`color` or "inherit"',
25922596
validator=validate_color_or_inherit,
2593-
description="background patch boundary color"
2597+
description="Color of the legend frame. 'inherit' uses 'axes.facecolor'."
25942598
),
25952599
_Param(
25962600
"legend.linewidth",
25972601
default=None,
25982602
type=float | None,
25992603
validator=validate_float_or_None,
2600-
description="line width of the legend frame, None means inherit from "
2601-
"patch.linewidth"
2604+
description="Line width of the legend frame. None uses 'patch.linewidth'."
26022605
),
26032606
_Param(
26042607
"legend.fancybox",
26052608
default=True,
26062609
type=bool,
26072610
validator=validate_bool,
2608-
description="if True, use a rounded box for the legend background, else a "
2609-
"rectangle"
2611+
description="If True, use a rounded box for the legend box, otherwise a "
2612+
"rectangle. See the *fancybox* parameter of `.Legend`."
26102613
),
26112614
_Param(
26122615
"legend.shadow",
26132616
default=False,
26142617
type=bool,
26152618
validator=validate_bool,
2616-
description="if True, give background a shadow effect"
2619+
description="Whether to draw a shadow behind the legend."
26172620
),
26182621
_Param(
26192622
"legend.numpoints",
26202623
default=1,
26212624
type=int,
26222625
validator=validate_int,
2623-
description="the number of marker points in the legend line"
2626+
description="Number of marker points in the legend when creating a legend "
2627+
"entry for a `.Line2D` (line)."
26242628
),
26252629
_Param(
26262630
"legend.scatterpoints",
26272631
default=1,
26282632
type=int,
26292633
validator=validate_int,
2630-
description="number of scatter points"
2634+
description="Number of scatter points in the legend when creating a legend "
2635+
"entry for a `.PathCollection` (scatter plot)."
26312636
),
26322637
_Param(
26332638
"legend.markerscale",
26342639
default=1.0,
26352640
type=float,
26362641
validator=validate_float,
2637-
description="the relative size of legend markers vs. original"
2642+
description="Relative size of legend markers compared to the data markers."
26382643
),
26392644
_Param(
26402645
"legend.fontsize",
26412646
default="medium",
26422647
type=_FontSizeType,
26432648
validator=validate_fontsize,
2644-
description="The font size of legend text."
2649+
description="Font size of legend text."
26452650
),
26462651
_Param(
26472652
"legend.labelcolor",
26482653
default="None",
26492654
type=':mpltype:`color` or {"linecolor", "markerfacecolor", "markeredgecolor"}',
26502655
validator=_validate_color_or_linecolor,
2651-
description="The color of the labels in legend entries. The special values "
2656+
description="Color of the labels in legend entries. The special values "
26522657
"'linecolor', 'markerfacecolor', and 'markeredgecolor' "
26532658
"infer the color from the associated legend handle; i.e. using "
26542659
"'linecolor' will render the label of a red line also in red."
@@ -2658,55 +2663,57 @@ class _Subsection:
26582663
default=None,
26592664
type=_FontSizeType | None,
26602665
validator=validate_fontsize_None,
2661-
description="None sets to the same as the default axes."
2666+
description="Font size of the legend title. None uses 'font.size'."
26622667
),
26632668
_Param(
26642669
"legend.borderpad",
26652670
default=0.4,
26662671
type=float,
26672672
validator=validate_float,
2668-
description="border whitespace"
2673+
description="Spacing between legend content and the border of the legend "
2674+
"box, in font-size units."
26692675
),
26702676
_Param(
26712677
"legend.labelspacing",
26722678
default=0.5,
26732679
type=float,
26742680
validator=validate_float,
2675-
description="the vertical space between the legend entries"
2681+
description="Vertical spacing between the legend entries, in font-size units."
26762682
),
26772683
_Param(
26782684
"legend.handlelength",
26792685
default=2.0,
26802686
type=float,
26812687
validator=validate_float,
2682-
description="the length of the legend lines"
2688+
description="Length of the legend handles, in font-size units."
26832689
),
26842690
_Param(
26852691
"legend.handleheight",
26862692
default=0.7,
26872693
type=float,
26882694
validator=validate_float,
2689-
description="the height of the legend handle"
2695+
description="Height of the legend handles, in font-size units."
26902696
),
26912697
_Param(
26922698
"legend.handletextpad",
26932699
default=0.8,
26942700
type=float,
26952701
validator=validate_float,
2696-
description="the space between the legend line and legend text"
2702+
description="The pad between the legend handle and text, in font-size units."
26972703
),
26982704
_Param(
26992705
"legend.borderaxespad",
27002706
default=0.5,
27012707
type=float,
27022708
validator=validate_float,
2703-
description="the border between the axes and legend edge"
2709+
description="The pad between the axes and legend border, in font-size units."
27042710
),
27052711
_Param(
27062712
"legend.columnspacing",
27072713
default=2.0,
27082714
type=float,
2709-
validator=validate_float, description="column separation"
2715+
validator=validate_float,
2716+
description="The spacing between columns, in font-size units."
27102717
),
27112718
_Section(
27122719
"Lines",

0 commit comments

Comments
 (0)