Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.1k
Add legend.linewidth parameter to control legend box edge linewidth#30780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Changes fromall commits
8f42926d92308c6d4de611d7ed10c931dc685417482dee1596f24f53File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
timhoffm marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| ``legend.linewidth`` rcParam and parameter | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| A new rcParam ``legend.linewidth`` has been added to control the line width of | ||
| the legend's box edges. When set to ``None`` (the default), it inherits the | ||
| value from ``patch.linewidth``. This allows for independent control of the | ||
| legend frame line width without affecting other elements. | ||
| The `.Legend` constructor also accepts a new *linewidth* parameter to set the | ||
| legend frame line width directly, overriding the rcParam value. | ||
| .. plot:: | ||
| :include-source: true | ||
| :alt: A line plot with a legend showing a thick border around the legend box. | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Using the | ||
| import matplotlib.pyplot as plt | ||
| fig, ax = plt.subplots() | ||
| ax.plot([1, 2, 3], label='data') | ||
| ax.legend(linewidth=2.0) # Thick legend box edge | ||
| plt.show() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -562,6 +562,7 @@ | ||
| #legend.framealpha: 0.8 # legend patch transparency | ||
| #legend.facecolor: inherit # inherit from axes.facecolor; or color spec | ||
| #legend.edgecolor: 0.8 # background patch boundary color | ||
| #legend.linewidth: None # line width of the legend frame, None means inherit from patch.linewidth | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. It seems we have a mixture already in that we sometimes use "inherit" and sometimes None. We should do an analysis of the cases and decide which one to use in the future. ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I see the point about consistency. I followed the edgecolor pattern which uses "inherit". Happy to adjust based on the team's preferred convention. Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Unfortunately, we are inconsistent already. rcParams using inherit:
rcParams using None:
rcParams using auto
Summary ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Thanks for clarifying. Is there anything needed from my side to move this PR forward being merged? | ||
| #legend.fancybox: True # if True, use a rounded box for the | ||
| # legend background, else a rectangle | ||
| #legend.shadow: False # if True, give background a shadow effect | ||
Uh oh!
There was an error while loading.Please reload this page.