Skip to content

Inconsistent linestyle specifications between Line2D and Patch artists #2136

Closed

Description

@WeatherGod

Just noticed that to get a dashed line in a line plot:

plt.plot([1, 2, 3, 4], [1, 2, 3, 4], '--')

is completely different from how to specify a line style elsewhere, such as bar():

plt.bar([1, 2, 3, 4], [1, 2, 3, 4], ls='dashed')

It would make sense to me to normalize these two specifications together so that either "accent" of linestyle specifications would work anywhere a "linestyle" argument is accepted.

Activity

  1. pelson commented on Sep 20, 2013

    @pelson
    Member

    👍

  2. ninjasoul commented on Sep 28, 2013

    @ninjasoul

    Hi. I would like to look into this issue. I am fairly new to Python and would love to take this opportunity to learn more about contributing to Python open-source projects.
    Just wondering if it would require any C knowledge?

  3. WeatherGod commented on Sep 28, 2013

    @WeatherGod
    MemberAuthor

    That would be great! This one will be a toughie. Not only will it require
    code work, but documentation and tests will be needed as well.

    We have a developer guide on our website that gives a basic idea on how to
    contribute to matplotlib. Every project is a little different, but is
    usually documented.

  4. ninjasoul commented on Sep 28, 2013

    @ninjasoul

    Thanks. I will look into the developer guide.

  5. lennart0901 commented on Jul 10, 2014

    @lennart0901
    Contributor

    ninjasoul are you still looking into this?
    Otherwise, I'd take a shot.

  6. ninjasoul commented on Jul 11, 2014

    @ninjasoul

    lennart0901 go ahead. I've not been able to pursue this.

  7. lennart0901 commented on Jul 15, 2014

    @lennart0901
    Contributor

    The api is rather inconsistent with respect to linestyles and dash patterns.
    Before I'm going to implement something there, I need some clarification.

    • In collections.py linestyles are converted to dash patterns. Those are also returned be the get method.
    • In lines.py the dash pattern is in dashes "property". if dashes is set, the linestyle is "dashed".
    • patches do not support dashes at all at the moment.

    How much backward compatibility should be preserved? To me it makes most sense to change either the collections or lines to reflect the same style, either convert to dashes or have a dashes property...

  8. WeatherGod commented on Jul 15, 2014

    @WeatherGod
    MemberAuthor

    I would go with the approach of letting both forms of the linestyle
    specifications be allowed in both places. This maintains backwards
    compatibility and lets users use to either form "get what they expect".

    I wouldn't worry about patches at the moment.

    On Tue, Jul 15, 2014 at 5:44 AM, lennart0901 notifications@github.com
    wrote:

    The api is rather inconsistent with respect to linestyles and dash
    patterns.
    Before I'm going to implement something there, I need some clarification.

    • In collections.py linestyles are converted to dash patterns. Those
      are also returned be the get method.
    • In lines.py the dash pattern is in dashes "property". if dashes is
      set, the linestyle is "dashed".
    • patches do not support dashes at all at the moment.

    How much backward compatibility should be preserved? To me it makes most
    sense to change either the collections or lines to reflect the same style,
    either convert to dashes or have a dashes property...

    —
    Reply to this email directly or view it on GitHub
    #2136 (comment)
    .

  9. lennart0901 commented on Jul 15, 2014

    @lennart0901
    Contributor

    It did not mean I want to remove any way one can specify line/dash-patterns.
    The question is what the getter-methods should return.

  10. added this to the milestone on Aug 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    API: consistencyConsistency of the matplotlib API, including naming, behavior, defaults, …

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions