Skip to content

Soft-deprecate dashes in favor of linestyle #17483

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
4 tasks
timhoffm opened this issue May 22, 2020 · 4 comments
Open
4 tasks

Soft-deprecate dashes in favor of linestyle #17483

timhoffm opened this issue May 22, 2020 · 4 comments

Comments

@timhoffm
Copy link
Member

timhoffm commented May 22, 2020

dashes are just a more limited form of linestyles. Actually, they are no more than:

    def set_dashes(self, seq):
        if seq == (None, None) or len(seq) == 0:
            self.set_linestyle('-')
        else:
            self.set_linestyle((0, seq))

I propose to soft-deprecate dashes in favor of linestyle. Dashes are redundant and thus only increase the API complexity without any benefit. OTOH I don't think we should deprecate dashes because there might be quite a bit of code out there using it.

Specific actions for this task:

  • linestyle should directly accept a dash pattern. - It currently only accepts (offset, dash_pattern).
  • Change all internal code and examples to use set_linestyle.
  • In set_dashes, recommend to use set_linestyle instead.
  • Add an API change note along the lines.
@mwaskom
Copy link

mwaskom commented May 23, 2020

seaborn uses dashes in lineplot so it would be best if this deprecation could be as soft as possible.

One point I would make is that the line._linestyle attribute does not track all of the information provided about how to draw the dashes:

    def set_linestyle(self, ls):
        if isinstance(ls, str):
            ds, ls = self._split_drawstyle_linestyle(ls)
            if ds is not None:
                self.set_drawstyle(ds)

            if ls in [' ', '', 'none']:
                ls = 'None'

            cbook._check_in_list([*self._lineStyles, *ls_mapper_r], ls=ls)
            if ls not in self._lineStyles:
                ls = ls_mapper_r[ls]
            self._linestyle = ls
        else:
            self._linestyle = '--'

If you're going to be modifying the linestyle code to take the dash patterns directly, it might be good to fix how that works.

@timhoffm
Copy link
Member Author

@mwaskom thanks for the comment. Which untracked information are you referring to specifically? Note that passing the drawstyle as part of the linestyle has been deprecated in 3.1 (#12442) and is removed for 3.3.

@mwaskom
Copy link

mwaskom commented May 25, 2020

Sorry, I mean that any kind of quantitative dash pattern (passed to linestyle or dashes) gets stored as the simple string "--", with no obvious public access to the actual dash sequence.

f, ax = plt.subplots()
line, = ax.plot([0, 1], linestyle=(0, (4, 1)))
line.get_linestyle()
"--"

@timhoffm timhoffm added this to the v3.4.0 milestone May 25, 2020
@QuLogic
Copy link
Member

QuLogic commented May 26, 2020

See also #17316 and #11797.

@QuLogic QuLogic modified the milestones: v3.4.0, v3.5.0 Jan 27, 2021
@QuLogic QuLogic modified the milestones: v3.5.0, v3.6.0 Sep 25, 2021
@QuLogic QuLogic modified the milestones: v3.6.0, v3.7.0 Jul 8, 2022
@timhoffm timhoffm modified the milestones: v3.7.0, future releases Dec 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants