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

Impossible to configure minor/major grid line style independently in rcParams · Issue #13919 · matplotlib/matplotlib · GitHub

Repository navigation

Impossible to configure minor/major grid line style independently in rcParams #13919

Closed

Description

Hi,

As far as I can see, the only customization to the grid that is possible right now in rcParams is:

mpl.rcParams['grid.color']  
mpl.rcParams['grid.alpha']
mpl.rcParams['grid.linewidth']
mpl.rcParams['grid.linestyle']

Is it possible to change these keys so that it is possible to configure minor and major grid line styles independently from each other?

Something like:

mpl.rcParams['grid.minor.color']  
mpl.rcParams['grid.minor.alpha']
mpl.rcParams['grid.minor.linewidth']
mpl.rcParams['grid.minor.linestyle']
mpl.rcParams['grid.major.color']  
mpl.rcParams['grid.major.alpha']
mpl.rcParams['grid.major.linewidth']
mpl.rcParams['grid.major.linestyle']

Activity

  1. timhoffm commented on Apr 14, 2019

    Member

    There are no separate parameters for major/minor grid properties in rcParams.

    You can currently only configure them programmatically.

    import matplotlib.pyplot as plt
    from matplotlib.ticker import MultipleLocator
    
    x = np.arange(10)
    
    ax = plt.gca()
    ax.plot(x, x**2)
    ax.xaxis.set_minor_locator(MultipleLocator(0.5))
    ax.grid(which='both')
    ax.tick_params(which='minor', grid_linestyle='--')
    
  2. zertrin commented on Apr 15, 2019

    I was just looking for exactly this feature. I already did it programmatically before, but as I have a large number of different plots with major and minor gridlines, this is quite inconvenient.

    Looking forward such an option in rcParams!

  3. dgua commented on Apr 8, 2020

    Yes, PLEASE. I'm with @NGJROMO.
    The programmatic way shown above is too cumbersome (and, is there a way to also set line width, color, and alpha?).

    This is back to one year ago. Is there any way it can be implemented soon?

    Here is what I want:

    Thanks.

  4. hjstein commented on Apr 21, 2020

    I'm surprised that the settings are not automatically mirrored in the style sheet & rcParams. In fact, I would have thought that all of the defaults would be set up in rcParams & that would drive everything else.

  5. neutrinonerd3333 commented on Nov 23, 2021

    Bumping this issue -- I've found it unwieldy to copy and paste the same code snippet to get a fixed style that I almost always want, and would also appreciate support for differently styled major and minor gridlines via rc params.

  6. jklymak commented on Nov 23, 2021

    Member

    A motivated user could always write a PR for this. https://matplotlib.org/stable/devel/contributing.html However, be aware that new rcparams face a relatively high bar for acceptance.

    One can also write their own styling wrapper if they are always doing this.

    import matplotlib.pyplot as plt 
    
    my_style_subplots(*arg, **kwargs):
        fig, axs = plt.subplots(*args, **kwargs)
        for ax in axs.flat:
           ax.xaxis.set_minor_locator(MultipleLocator(0.5))
           ax.grid(which='both')
           ax.tick_params(which='minor', grid_linestyle='--')
        return fig, axs
    import mystyles as myplt
    
    fig, ax = mplt.subplots(3, 2, sharedx=True)
  7. dgua commented on Nov 23, 2021

    Sorry but above answer isn't satisfactory IMHO. That is not what we are asking. Also, it forces ax.xaxis.set_minor_locator(MultipleLocator(0.5)), which I would not want in general.

    This is a straightforward request and not hard to implement. It's from 2019 for crying out loud.

  8. jklymak commented on Nov 23, 2021

    Member

    This is a straightforward request and not hard to implement. It's from 2019 for crying out loud.

    Matplotlib is a volunteer organization and PRs are always welcome!

  9. DanHallatt commented on Feb 5, 2022

    I agree with @neutrinonerd3333, and am in the same boat as him and @zertrin.

    One other thing that I think is related, is the inability to specify tick label font in rcParams. I am able to specify the overall general font as Helvetica for example, successfully changing the font of everything in my generated plots, however this does not change the font of the tick labels (they remain in a serif font..)! I thought I could specify this in the rcParams (with something like font..ticklabel.family: sans-serif, font.ticklabel.serif: Helvetica), but it turns out this is another limitation that must be done programmatically... making each of my plots even more cumbersome and repetitive to code.

  10. github-actions commented on Jun 12, 2023

    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 Jun 12, 2023

    Member

    This is a highly requested feature. -> keep

  12. added
    keepItems to be ignored by the “Stale” Github Action
    and removed
    status: inactiveMarked by the “Stale” Github Action
    on Jun 12, 2023
  13. YamenMejri commented on Dec 16, 2023

    any updates on this?

  14. nNeD5 commented on Apr 17, 2024

    Still need this feature

  15. added
    🌱 Good first issueOpen a pull request against these issues if there are no active ones!
    Difficulty: Mediumhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issues
    on Apr 17, 2024
  16. github-actions commented on Apr 17, 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
    .

  17. jklymak commented on Apr 17, 2024

    Member

    Maybe some extra tagging will help, but someone who wants this feature needs to propose a PR for it to get implemented.

  18. timhoffm commented on Apr 19, 2024

    Member

    As a word of warning: This is not as trivial as it sounds. We want to maintain backward-compatibility, i.e. if somebody changes th grid.* parameters, they should still affect both grids - unless of course they specify grid.minor.* explicitly. This possibly needs some hierachial lookup/dependency between the keys, which is not a concept we have in rcParams so far.

  19. added this to the v3.11.0 milestone on Jun 24, 2025
  20. removed
    keepItems to be ignored by the “Stale” Github Action
    on Jun 24, 2025
  21. carlosgmartin commented on Nov 15, 2025

    Contributor

    @QuLogic @timhoffm The new options, like grid.major.color, don't show up in "The default matplotlibrc file" in the docs. Is this expected?

  22. timhoffm commented on Nov 15, 2025

    Member

    @carlosgmartin As you can see from the milestone assignment, this will be released in 3.11. The stable docs are currently 3.10.7. You can find the dev version of the docs at https://matplotlib.org/devdocs/users/explain/customizing.html

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

    Difficulty: Mediumhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesNew featuretopic: rcparams🌱 Good first issueOpen a pull request against these issues if there are no active ones!

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL