FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

About linestyles: tuple not accepted in rc param file and other inconsistencies · Issue #11797 · matplotlib/matplotlib · GitHub

Repository navigation

About linestyles: tuple not accepted in rc param file and other inconsistencies #11797

Open

Description

This is related to #8040 and #9797, possibly #7219.

Bug report

Apart from strings like "-", "--", ":" , the linestyle can also be set as a tuple of an on/off sequence. There are however two different notations,

  • (on, off, on, off, ...) and
  • (start, (on, off, on, off, ...)).

For all of the ways to set the linestyle, only one or none of those actually work.

Most importantly there is currently no way to set an on/off linestyle via the rc file.


The following lists those combinations and whether they work or not with the respective commands.

linestyle /dashes inside plot function

command working
plt.plot([1,2], linestyle=":") ✔️
plt.plot([1,2], linestyle=(5,1,1,1)) ❌
plt.plot([1,2], linestyle=(0,(5,1,1,1))) ✔️
plt.plot([1,2], dashes=":") ❌
plt.plot([1,2], dashes=(5,1,1,1)) ✔️
plt.plot([1,2], dashes=(0, (5,1,1,1))) ❌

using rcParams

command working
plt.rcParams["grid.linestyle"] = ":" ✔️
plt.rcParams["grid.linestyle"] = (5,1,1,1) ✔️
plt.rcParams["grid.linestyle"] = (0,(5,1,1,1)) ❌

inside cycler using rcParams

command working
plt.rcParams["axes.prop_cycle"] += plt.cycler("linestyle", [":"]) ✔️
plt.rcParams["axes.prop_cycle"] += plt.cycler("linestyle", [(5,1,1,1)]) ❌
plt.rcParams["axes.prop_cycle"] += plt.cycler("linestyle", [(0,(5,1,1,1))]) ✔️

using rc file

command working
grid.linestyle : : ✔️
grid.linestyle : (5,1,1,1) ❌
grid.linestyle : (0,(5,1,1,1)) ❌

inside cycler using rc file

command working
axes.prop_cycle : cycler("linestyle", [":"] ) ✔️
axes.prop_cycle : cycler("linestyle", [(5,1,1,1)] ) ❌
axes.prop_cycle : cycler("linestyle", [(0,(5,1,1,1))] ) ❌

Correlation

command string ":" tuple (5,1,1,1) tuple (0,(5,1,1,1))
plt.plot(..., linestyle=x) ✔️ ❌ ✔️
plt.plot(..., dashes=x) ❌ ✔️ ❌
plt.rcParams["grid.linestyle"] = x ✔️ ✔️ ❌
plt.rcParams["axes.prop_cycle"] += plt.cycler("linestyle", [x]) ✔️ ❌ ✔️
rc file grid.linestyle : x ✔️ ❌ ❌
rc file axes.prop_cycle : cycler("linestyle", [x] ) ✔️ ❌ ❌

I think the first thing to do here is to identify which combinations should actually work.

attn. @afvincent who has last worked on validation of linestyle rc Parameters.

Activity

  1. added this to the v3.3.0 milestone on Sep 1, 2019
  2. anntzer commented on Jan 21, 2020

    Contributor

    Many cases (not all) were fixed by #15827.

  3. modified the milestones: v3.3.0, v3.4.0 on May 7, 2020
  4. modified the milestones: v3.4.0, v3.5.0 on Jan 27, 2021
  5. modified the milestones: v3.5.0, v3.6.0 on Sep 25, 2021
  6. modified the milestones: v3.6.0, v3.7.0 on Aug 24, 2022
  7. modified the milestones: v3.7.0, v3.7.1 on Feb 14, 2023
  8. removed this from the v3.7.1 milestone on Mar 4, 2023
  9. 1 remaining item

  10. github-actions commented on Aug 16, 2024

    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!

  11. timhoffm commented on Aug 21, 2024

    Member

    To move forward or close this, it would be good to recreate the initial tables on what works and what not with the current version of matplotlib.

    I'm marking this as good first issue for recreating the tables. Further actions will need to be discussed on the result.

  12. added
    🌱 Good first issueOpen a pull request against these issues if there are no active ones!
    on Aug 21, 2024
  13. github-actions commented on Aug 21, 2024

    Good first issue - notes for new contributors

    This issue is suited to new contributors because it does not require understanding of the
    Matplotlib internals. To get started, please see our contributing
    guide
    .

    We do not assign issues. Check the Development section in the sidebar for linked pull
    requests (PRs). If there are none, feel free to start working on it. If there is an open PR, please
    collaborate on the work by reviewing it rather than duplicating it in a competing PR.

    If something is unclear, please reach out on any of our communication
    channels
    .

  14. timhoffm commented on Aug 21, 2024

    Member

    As good first issue: It would be good to recreate the initial tables on what works and what not with the current version of matplotlib.

  15. added
    keepItems to be ignored by the “Stale” Github Action
    and removed
    status: inactiveMarked by the “Stale” Github Action
    on Aug 21, 2024
  16. QuLogic commented on Aug 31, 2024

    Member

    I thought @oscargus looked into this wrt dashes and linestyles?

  17. saumyacoder1709 commented on Jan 1, 2026

    Contributor

    I would like to work on this issue. Can somebody guide me what it needs?

  18. timhoffm commented on Jan 2, 2026

    Member

    @saumyacoder1709 start with #11797 (comment)

    As a general remark, we don't have the capacity to guide. We expect contributors to be able to understand and reproduce the issue, and come up with a reasonable solution suggestion based on the given information. Please be sure to have read and undstood our contribution guildelines and the complete issue thread.

  19. maederan201 commented on Jan 28, 2026

    Hello,

    I recreated the tables as requested above using the current matplotlib version, here's the overview:

    linestyle/dashed inside plot function

    command working
    plt.plot([1,2], linestyle=":") ✔️
    plt.plot([1,2], linestyle=(5,1,1,1)) ❌
    plt.plot([1,2], linestyle=(0,(5,1,1,1))) ✔️
    plt.plot([1,2], dashes=":") ❌
    plt.plot([1,2], dashes=(5,1,1,1)) ✔️
    plt.plot([1,2], dashes=(0, (5,1,1,1))) ❌

    using rcParams

    command working
    plt.rcParams["grid.linestyle"] = ":" ✔️
    plt.rcParams["grid.linestyle"] = (5,1,1,1) ✔️
    plt.rcParams["grid.linestyle"] = (0,(5,1,1,1)) ✔️

    inside cycler using rcParams

    command working
    plt.rcParams["axes.prop_cycle"] += plt.cycler("linestyle", [":"]) ✔️
    plt.rcParams["axes.prop_cycle"] += plt.cycler("linestyle", [(5,1,1,1)]) ❌*
    plt.rcParams["axes.prop_cycle"] += plt.cycler("linestyle", [(0,(5,1,1,1))]) ✔️
    • The command works, but the plotting subsequently fails

    using rc file

    command working
    grid.linestyle : : ✔️
    grid.linestyle : (5,1,1,1) ✔️
    grid.linestyle : (0,(5,1,1,1)) ✔️

    inside cycler using rc file

    command working
    axes.prop_cycle : cycler("linestyle", [":"] ) ✔️
    axes.prop_cycle : cycler("linestyle", [(5,1,1,1)] ) ✔️
    axes.prop_cycle : cycler("linestyle", [(0,(5,1,1,1))] ) ✔️

    From a quick glance over the missing ones, it seems some adjustments in lines.py are required. I will try and make those and produce a PR.

  20. maederan201 commented on Jan 28, 2026

    Creating a fix such that the commands above all work was sufficiently easy, however this raised some other issues.

    Am I correct in assuming that the (offset, (on, off, on, off, ...)) way of setting dashes is the one that should be used in the backend everywhere?

    In that case it is just a case of translating single tuples and strings like ":" to have offset 0.

  21. added
    🌱 Good first issueOpen a pull request against these issues if there are no active ones!
    and removed
    🌱 Good first issueOpen a pull request against these issues if there are no active ones!
    on Aug 22, 2026
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, …keepItems to be ignored by the “Stale” Github Actiontopic: rcparams🌱 Good first issueOpen a pull request against these issues if there are no active ones!

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL