Skip to content

Enhancement Request: grid below and ticks above #4243

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
u55 opened this issue Mar 18, 2015 · 3 comments
Open

Enhancement Request: grid below and ticks above #4243

u55 opened this issue Mar 18, 2015 · 3 comments
Labels
keep Items to be ignored by the “Stale” Github Action New feature

Comments

@u55
Copy link
Contributor

u55 commented Mar 18, 2015

Hi matplotlib developers,

Currently, it is not possible to have the gridlines drawn below plotlines and simultaneously have ticks drawn above plotlines. With the set_axisbelow method, the gridlines and ticks are both set either above or below any plotlines. Here is a minimal working example:

import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt

mpl.rcParams.update({
'font.size':16,
'axes.linewidth':6,
'xtick.major.width':4,
'ytick.major.width':4,
'xtick.major.size':13,
'ytick.major.size':13,
'grid.linewidth':4,
'grid.color':'0.8',
})

x = np.log(np.linspace(1e-3,1e+3,1e+3))

plt.figure()

ax1 = plt.subplot(211)
ax1.plot(x,lw=10)
ax1.set_xlim(-10,1000)
ax1.set_ylim(-8,6.8)
ax1.grid()
ax1.set_axisbelow(False)

ax2 = plt.subplot(212)
ax2.plot(x,lw=10)
ax2.set_xlim(-10,1000)
ax2.set_ylim(-8,6.8)
ax2.grid()
ax2.set_axisbelow(True)

plt.show()

grid_below

In the example above, in the top subplot, the set_axisbelow(False) method makes the gridlines above the plotline; while in the bottom subplot, the set_axisbelow(True) method makes the plotline above the ticks. This is unfortunate because, in my typical use case, I never want the gridlines above the data and I never want the ticks below the data, so I have to "simulate" a fake grid by drawing individual lines with axvline and axhline. This missing functionality was noticed at stackoverflow
http://stackoverflow.com/questions/19677963/matplotlib-keep-grid-lines-behind-the-graph-but-the-y-and-x-axis-above
a while ago, where it was called a "feature" by @tacaswell , so I am requesting a new functionality that would allow the gridlines to be set below all other artists without affecting the axis spines or ticks. Perhaps a new axes method named set_gridbelow would do the trick, or an optional kwarg to set_axisbelow.

In any case, I can't believe that I am the only person who wants this functionality to be built-in, so I hope that you consider adding this enhancement. Thanks.

@petehuang
Copy link
Contributor

#6287 does not separate ticks and grids, so that does not directly address this, but it does mention that doing so would require significant refactoring. Worth considering to evaluate impact-effort tradeoff for this

@tacaswell tacaswell modified the milestones: 2.2 (next next feature release), 2.1 (next point release) Jan 10, 2017
@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 Mar 11, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 11, 2023
@oscargus
Copy link
Member

I'll reopen this as it seems like a sensible request.

@oscargus oscargus reopened this Apr 11, 2023
@oscargus oscargus added keep Items to be ignored by the “Stale” Github Action and removed status: inactive Marked by the “Stale” Github Action labels Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
keep Items to be ignored by the “Stale” Github Action New feature
Projects
None yet
Development

No branches or pull requests

4 participants