Skip to content

Expose legend's line: legline._legmarker as public #20552

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

Closed
ianhi opened this issue Jun 30, 2021 · 6 comments
Closed

Expose legend's line: legline._legmarker as public #20552

ianhi opened this issue Jun 30, 2021 · 6 comments
Labels
Good first issue Open a pull request against these issues if there are no active ones! New feature
Milestone

Comments

@ianhi
Copy link
Contributor

ianhi commented Jun 30, 2021

Problem

I would like to be able to modify the alpha of both the line and marker in a legend as an extension of this example: https://matplotlib.org/stable/gallery/event_handling/legend_picking.html

However, currently the only way to access the marker in in the legend in order to set it's alpha value is via the private legline._legmarker attribute.

legline._legmarker = legline_marker

This is not ideal for the reasons that @jklymak noted in #9155 (comment)

This is pretty hacky, and the undrscore means it could go away.

So with the current public api the best you can achieve is:
image

when what I want is:
image

Proposed Solution

The simplest solution would be to drop the underscore on the legmarker and add modifying the marker to the example as a way of documenting.

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

Labeling this as a good first issue as the tasks are:

  • remove an underscore (in several places)
  • add a new-feature note
  • add example

might be worth keeping the _ version around to be kind to anyone who was using this "un-officially" but am 50/50 on that.

timhoffm added a commit to timhoffm/matplotlib that referenced this issue Jun 30, 2021
- Link to Sphinx reStructuredText primer.
- `make show` for opening locally built docs.

Closes matplotlib#20552.
@QuLogic
Copy link
Member

QuLogic commented Jun 30, 2021

Looks like a typo in the issue number.

@QuLogic QuLogic reopened this Jun 30, 2021
@ianhi
Copy link
Contributor Author

ianhi commented Jun 30, 2021

might be worth keeping the _ version around to be kind to anyone who was using this "un-officially" but am 50/50 on that.

I'm 👍 on keeping the _ version with a (deprecation?) warning attached. There are ~1000 results on github for _legmarker https://github.com/search?q=_legmarker&type=code and on a personal note my newest pypi package uses it.

Edit:

It's even used in some pretty big and downloaded repos: https://github.com/h2oai/h2o-3/blob/177b9097febf3275c7651a766d2ecf316fe7f0e8/h2o-py/h2o/model/extensions/std_coef.py

@QuLogic
Copy link
Member

QuLogic commented Jun 30, 2021

I think this would effectively be fixed by #11358.

@anntzer
Copy link
Contributor

anntzer commented Jun 30, 2021

Agreed that #11358 would be nice.

@param-thakker
Copy link

Hi @tacaswell, is this still open? I'm a first time contributor and would love to work on it.

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

5 participants