Open luisdelatorre012 opened 7 years ago
It looks current impl doesn't care axes.grid.axis
. PR is welcome.
https://github.com/pandas-dev/pandas/blob/master/pandas/plotting/_core.py#L140
This is still an issue.
This is due to https://github.com/pandas-dev/pandas/blob/6fd01648b6d14b24690b85f993b193699df12439/pandas/plotting/_matplotlib/core.py#L574
Pandas adds a grid to an axes using https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.grid.html
This function takes two optional parameters, one to set which axis to apply the grid to and one to set which ticks (major or minor). Both parameters default to specific values (both axis, major ticks) not the rcParams setting. This means that pandas users have no way to set these parameters as the rcParams setting isn't being used and the pandas API has no way to set these either.
At a minimum, pandas should be pulling the rcParams "axes.grid.axis" and "axes.grid.which" and using those in the function call to axes.grid. There may be some interest in also extending the pandas api to include these parameters, but I don't think that is necessary now.
I'm not comfortable contributing to this large of a project as I'm not set up to run tests and such. However, I've tried out the following fix and think it should work. Could someone else put in a pull request?
Changes to:
ax.grid(self.grid, axis=self.plt.rcParams["axes.grid.axis"], which=self.plt.rcParams["axes.grid.which"])
Found the same issue. Seems to be still open in 2023.
take
Problem description
Matplotlib style files have an option axes.grid.axis: with valid values both, x, or y. Using the value y should result in plotting only horizontal gridlines. When plotting with DataFrame.plot(), both vertical and horizontal gridlines are displayed. The code below plots an example of the behavior. The mplstyle file linked to contains only these two options.
If instead you plot with Matplotlib directly, using
ax.bar(d['Month'], d['Volume'])
, you get the expected output of only horizontal lines.