Skip to content

Line2D dash pattern getter #17316

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

Open
MaozGelbart opened this issue May 3, 2020 · 3 comments · May be fixed by #23056
Open

Line2D dash pattern getter #17316

MaozGelbart opened this issue May 3, 2020 · 3 comments · May be fixed by #23056

Comments

@MaozGelbart
Copy link
Contributor

Bug report

Bug summary

For lines.Line2D, there exists line.get_linestyle() which returns a short string representation of one of the four preconfigured line styles ("-"/"--"/":"/"-."). For the "dashed" ("--") style, which is returned wherever the linestyle input is a tuple (or dashes kwarg was used or set_dashes was called with tuple input), the exact dash pattern is not returned. There's no line.get_dashes().

On the contrary, collections.LineCollection([], linestyle=style).get_linestyle() returns the (scaled) dash pattern and not the preconfigured linestyle, which is more general and helpful. collection.get_dashes() is an alias for get_linestyle().

Is it possible to add a getter for the (unscaled) original dash pattern of a line2d instance?

Code for reproduction

#linestyle input to line2d can be queried but dash pattern is not exposed
from matplotlib import lines
line = lines.Line2D([],[],linestyle=(0,(2,2)))
line.get_linestyle()  # "--"
#similar dashing input to lineCollection
from matplotlib import collections
collection = collections.LineCollection([], linestyle=(0,(2,2)))
collection.get_linestyle()  # [(0.0, [3.0, 3.0])]

Actual outcome

'--'
[(0.0, [3.0, 3.0])]

Expected outcome

Matplotlib version

  • Matplotlib version: 3.2.1

Many thanks for considering this!

@github-actions
Copy link

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Jul 31, 2023
@QuLogic
Copy link
Member

QuLogic commented Jul 31, 2023

I think @oscargus has a PR on this, so it shouldn't be closed until then.

@QuLogic QuLogic removed the status: inactive Marked by the “Stale” Github Action label Jul 31, 2023
@rcomer
Copy link
Member

rcomer commented Dec 13, 2024

We are overall not consistent and clear what get_linestyle() means:

  • for Line2D.get_linestyle() it is always a str, and if given a dash pattern, the result is "--".
  • for Patch.get_linestyle(), we basically get what we put in str or (unscaled) dash pattern; with the exception of normalizing "no style" ' ', '', 'none' to "None"
  • for Collections, we always get a scaled dash pattern.

... we should generally agee upon what get_linestyle() means - and a scaled dash pattern would be the last of my choices.

Originally posted by @timhoffm in #29302 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants