Skip to content
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

add legend.labelcolor "argument" to mplstyle stylesheet #20049

Closed
luke-m-olson opened this issue Apr 22, 2021 · 4 comments
Closed

add legend.labelcolor "argument" to mplstyle stylesheet #20049

luke-m-olson opened this issue Apr 22, 2021 · 4 comments
Labels
Good first issue Open a pull request against these issues if there are no active ones! New feature
Milestone

Comments

@luke-m-olson
Copy link

A useful argument, labelcolor, was introduced in version 3.3.0 for the textual labels in legends. This allows users to color these labels with the same color as the underlying line/marker, which in turn, allows user to remove the line/marker handle/icon in favor of the colored text label.

In settings where figures are produced in a very standardized manner and that manner requires the color of the legend labels standing in for the line/marker colors of the figure, a more compact representation, the requested feature would reduce coding burden for individuals, and more importantly reduce the burden among collaborators.

Proposed Solution

A logical extension of this great addition to plt.legend would be to (if possible) include the labelcolor option/argument in the matplotlib style sheet. Allowing legend.labelcolor: linecolor along with the various other options available to labelcolor in plt.legend() into the stylesheet could reduce some coding overhead and coordination issues where legends of this type (label color standing in as line/marker) are needed, especially in teams.

Additional context and prior art

@tacaswell tacaswell added this to the v3.5.0 milestone Apr 23, 2021
@tacaswell tacaswell added the Good first issue Open a pull request against these issues if there are no active ones! label Apr 23, 2021
@tacaswell
Copy link
Member

To implement this we would have to add an rcparam for legend.labelcolor (as that is the machinery that the style files feed into). A recent example of adding a new rcparams is: #17022 . The work is to:

  • add the validation code for the new value
  • add the default value to the matplotlbrc template
  • add the checking of the rcparam at the correct place in the code
  • document the new feature

Would you like to take a shot at implementing this @luke-m-olson ?

@Carloscerq
Copy link
Contributor

Hi, I am a beginner in the open-source world, can I try it?

@timhoffm
Copy link
Member

Go for it.

@tacaswell
Copy link
Member

Closed by #20084

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good first issue Open a pull request against these issues if there are no active ones! New feature
Projects
None yet
Development

No branches or pull requests

4 participants