You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Doc]: add gridlines to style sheet reference #23601
The only style sheet examples that show the default grid color in that style are the styles that turn grids on by default. I think it'd be useful to show which color the grid defaults to when turned on, in part to flag color choices such as #23598
Suggested improvement
I suggest turning on the grid for the line example since my guess is that's the most common use case for grids. This is a good-ish first issue since it involves adding something like an ax.grid call to one of the plots in the example (https://github.com/matplotlib/matplotlib/blob/main/examples/style_sheets/style_sheets_reference.py) but there might be lots of back and forth on the PR on which example gets the grid.
I think if the grid line color is considered part of the 'unchangable style API' then it should be documented, and I think the current way that style is documented is via this reference. This is the default if you call the grid function, just like the other examples show, for example, the default if you call the plot or scatter functions.
I'd be all for a new style sheet reference that visually documents what each individual element in the style sheet is set, but I think that's a bigger project.
The primary objective of the style sheet reference is to answer "How will my plot look like with this style". We need to show the basic appearance without any modifications applied. Whether the grid is shown is a fundametal sylistic element. - Yes you can activate the grid, but that's a modification like changeing linewidth. And should not be part of the basic illustration.
If you really want to show the grid color, we would have to make it very explicit in word and picture "If you activate the grid on this style it would look like this." I don't how to do this so that it's clear to the user but OTOH not too cluttered/confusing for people who are not interested in that detail.
I see your point that one cannot see the grid color from the style if the grid is not visible. But I'd argue (1) the grid color is reasonable and thus not important that people would choose a style or not. Most people would be satisfied with the grid color and if not, people who are caring that much about styling can simply choose another color via ax.grid(color='red') instead of only activating ax.grid(True)`. I thus strongly favour leaving everything as is.
the grid color is reasonable and thus not important
#23598 exists because it's debatable whether the grid color is reasonable. I understand it's a small thing and probably not a priority, but I think that same can be said about each individual choice of the style, and that it's all of it collectively that adds up to a reason for choosing a style.
In a comment on #23730, @jklymak suggests flagging that the grid is/isn't the default (b/c as @Kinza-Raza mentions, it is the default for a bunch of the styles) via a small annotation. Or via a ..note: grid is on by default in [a, b, c, d] styles?
My two cents - since there's minimal documentation on this page a simple note wouldn't complicate comprehension or get lost in the way.
and that it's all of it collectively that adds up to a reason for choosing a style
I agree, gridlines on the line plots help set a clear distinction. For reference:
That being said perhaps a better note would be grid is enabled for line charts. And a better phrased sentence to highlight "grid is on by default for styles in which all charts have gridlines" .
Activity
masaaldosey commentedon Aug 19, 2022
Hi! If it is okay, I can work on this issue.
story645 commentedon Aug 19, 2022
Go for it! We generally don't assign issues, but first person with an open PR gets priority. https://matplotlib.org/devdocs/devel/index.html
jklymak commentedon Aug 20, 2022
The style sheet reference show what happens when you use the defaults, so turning the grid on in addition seems very misleading?
story645 commentedon Aug 21, 2022
I think if the grid line color is considered part of the 'unchangable style API' then it should be documented, and I think the current way that style is documented is via this reference. This is the default if you call the grid function, just like the other examples show, for example, the default if you call the plot or scatter functions.
I'd be all for a new style sheet reference that visually documents what each individual element in the style sheet is set, but I think that's a bigger project.
Kinza-Raza commentedon Aug 24, 2022
Hi @story645, was playing around a bit with the style sheet and noticed something interesting.
This enables the grid for default and classic, but disables it for all other styles for which it's currently enabled (e.g. Solarize_Light2, Seaborn) Could it be because of not passing any kwargs as the documentation here https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.grid.html#examples-using-matplotlib-axes-axes-grid says visible is set to True if kwargs are supplied.
Since the motive of this issue is to show the default colour of the grid, please have a look at my PR and let me know if it works.
story645 commentedon Aug 24, 2022
Yup, if no argument is passed then the setting is toggled. I think it may be better to be explicit and set
ax.grid(True)matplotlib/lib/matplotlib/axes/_base.py
Lines 3176 to 3177 in 36f2745
story645 commentedon Aug 25, 2022
Um @jklymak and @timhoffm, are either of your reservations strong enough to block merging #23730
timhoffm commentedon Aug 25, 2022
The primary objective of the style sheet reference is to answer "How will my plot look like with this style". We need to show the basic appearance without any modifications applied. Whether the grid is shown is a fundametal sylistic element. - Yes you can activate the grid, but that's a modification like changeing linewidth. And should not be part of the basic illustration.
If you really want to show the grid color, we would have to make it very explicit in word and picture "If you activate the grid on this style it would look like this." I don't how to do this so that it's clear to the user but OTOH not too cluttered/confusing for people who are not interested in that detail.
I see your point that one cannot see the grid color from the style if the grid is not visible. But I'd argue (1) the grid color is reasonable and thus not important that people would choose a style or not. Most people would be satisfied with the grid color and if not, people who are caring that much about styling can simply choose another color via
ax.grid(color='red') instead of only activatingax.grid(True)`. I thus strongly favour leaving everything as is.story645 commentedon Aug 25, 2022
#23598 exists because it's debatable whether the grid color is reasonable. I understand it's a small thing and probably not a priority, but I think that same can be said about each individual choice of the style, and that it's all of it collectively that adds up to a reason for choosing a style.
In a comment on #23730, @jklymak suggests flagging that the grid is/isn't the default (b/c as @Kinza-Raza mentions, it is the default for a bunch of the styles) via a small annotation. Or via a
..note: grid is on by default in [a, b, c, d]styles?Kinza-Raza commentedon Aug 26, 2022
My two cents - since there's minimal documentation on this page a simple note wouldn't complicate comprehension or get lost in the way.
I agree, gridlines on the line plots help set a clear distinction. For reference:
That being said perhaps a better note would be
grid is enabled for line charts. And a better phrased sentence to highlight "grid is on by default for styles in which all charts have gridlines" .jklymak commentedon Aug 26, 2022
Since this now has a PR perhaps easier to discuss there?
I'd suggest label on each panel either a small title or a text in the axes. I don't think folks will read the preamble.
QuLogic commentedon Oct 4, 2022
Closed by #24020, I think.