Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ENH: Add parameter to set line width of legend frame (closes #30095) #30103

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

AtharvaRai07
Copy link

@AtharvaRai07 AtharvaRai07 commented May 24, 2025

PR summary

This PR adds a new parameter framelinewidth to the legend() function to control the line width of the legend frame. This addresses issue #30095 where users requested the ability to customize the legend frame's line width.

Why is this change necessary?

Currently, users cannot customize the line width of the legend frame, which limits the visual customization options available for legends. This change provides more flexibility in legend styling.

What problem does it solve?

It solves the limitation where users cannot adjust the thickness of the legend frame border, allowing for better visual customization of legends to match different plot styles and preferences.

What is the reasoning for this implementation?

The implementation follows matplotlib's existing pattern of style customization parameters. It adds a new parameter framelinewidth that works similarly to other line width parameters in matplotlib, maintaining consistency with the library's API design.

Example:

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 10, 100)
plt.plot(x, np.sin(x), label='sin(x)')
plt.plot(x, np.cos(x), label='cos(x)')

# Create legend with custom frame line width
plt.legend(framelinewidth=2.0)  # Thicker frame
plt.show()

PR checklist

  • "closes [ENH]: Add parameter to set line width of legend frame #30095" is in the body of the PR description to link the related issue
  • new and changed code is tested
  • Plotting related features are demonstrated in an example
  • New Features and API Changes are noted with a directive and release note
  • Documentation complies with general and docstring guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join us on gitter for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide

We strive to be a welcoming and open project. Please follow our Code of Conduct.

@AtharvaRai07 AtharvaRai07 deleted the feature/legend-frame-linewidth branch May 24, 2025 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ENH]: Add parameter to set line width of legend frame
1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.