-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Doc]: add gridlines to style sheet reference #23601
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
Comments
Hi! If it is okay, I can work on this issue. |
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 |
The style sheet reference show what happens when you use the defaults, so turning the grid on in addition seems very misleading? |
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. |
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. |
Yup, if no argument is passed then the setting is toggled. I think it may be better to be explicit and set matplotlib/lib/matplotlib/axes/_base.py Lines 3176 to 3177 in 36f2745
|
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 |
#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 |
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 |
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. |
Closed by #24020, I think. |
Documentation Link
https://matplotlib.org/devdocs/gallery/style_sheets/style_sheets_reference.html
Problem
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.The text was updated successfully, but these errors were encountered: