Skip to content
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

Pandas DataFrame.plot() does not default to matplotlib rcparams grid setting #9792

Closed
jdavidheiser opened this issue Apr 2, 2015 · 5 comments · Fixed by #10212
Closed

Pandas DataFrame.plot() does not default to matplotlib rcparams grid setting #9792

jdavidheiser opened this issue Apr 2, 2015 · 5 comments · Fixed by #10212
Milestone

Comments

@jdavidheiser
Copy link

When using df.plot() to creat a simple line chart from a dataframe, the expected behavior is that, if no 'grid' keyword is passed, the plot will default to the matplotlib 'axes.grid' rcParam setting to determine whether to show a grid or not. However (in 0.16), the grid is always being shown, regardless of the matplotlib setting, unless I explicitly pass grid=False.

In general, there are several plot types where grid=True is forced, which basically breaks the consistent styling that you get from matplotlib rcparams or another package like Seaborn. I can understand forcing a default grid=False for the type of plots where a grid doesn't make sense, but forcing grid=True, overriding the configured defaults, for things like boxplots seems a bit counter intuitive.

@TomAugspurger
Copy link
Contributor

Agreed for the most part, but where do we draw the line (sorry for the bad pun). I'm not sure which plots grids makes sense on. I guess have grids for line, scatter, density. No grid for box. On barplots I usually only have gridlines along the y axis, but I'm not sure that's the best default. And which ones do we fall back to rcParams on?

@TomAugspurger TomAugspurger added this to the 0.16.1 milestone Apr 6, 2015
@jdavidheiser
Copy link
Author

my opinion is that they should fall back on rcparams for almost everything, except those where grid lines make no sense at all. The problem with overriding rcparams is that it 'breaks' the default matplotlib behavior for people who are used to using matplotlib.

@jreback jreback modified the milestones: 0.16.1, 0.17.0 Apr 28, 2015
@artemyk
Copy link
Contributor

artemyk commented May 26, 2015

I also ran into this issue and found it very confusing and --- worst of all --- in conflict with the documentation (which says that not passing in grid will result in matplotlib default)

@TomAugspurger
Copy link
Contributor

Should be a pretty simple fix if you're up to submitting a PR.

The signature should still be df.plot(..., grid=None, ...).

If the user specifies True or False, we use that.

If they leave the default of None, we either

  • override plt.RcParams for box and pie (setting grid=False)
  • fall back to rcParams otherwise

@artemyk
Copy link
Contributor

artemyk commented May 26, 2015

@TomAugspurger OK, I made a PR. box can go either way, I believe.

artemyk pushed a commit to artemyk/pandas that referenced this issue May 27, 2015
TomAugspurger pushed a commit that referenced this issue May 27, 2015
BUG: plot doesnt default to matplotlib axes.grid setting (#9792)
@jorisvandenbossche jorisvandenbossche modified the milestones: 0.17.0, 0.16.2 Jun 2, 2015
cgevans added a commit to cgevans/pandas that referenced this issue Jun 5, 2015
* https://github.com/pydata/pandas: (26 commits)
  disable some deps on 3.2 build
  Fix meantim typo
  DOC: use current ipython in doc build
  PERF: write basic datetimes faster pandas-dev#10271
  TST: fix for bottleneck >= 1.0 nansum behavior, xref pandas-dev#9422
  add numba example to enhancingperf.rst
  BUG: SparseSeries constructor ignores input data name
  BUG: Raise TypeError only if key DataFrame is not empty pandas-dev#10126
  ENH: groupby.apply for Categorical should preserve categories (closes pandas-dev#10138)
  DOC: add in whatsnew/0.17.0.txt
  DOC: move whatsnew from 0.17.0 -> 0.16.2
  BUG:  Holiday(..) with both offset and observance raises NotImplementedError pandas-dev#10217
  BUG: Index.union cannot handle array-likes
  BUG: SparseSeries.abs() resets name
  BUG: Series arithmetic methods incorrectly hold name
  ENH: Don't infer WOM-5MON if we don't support it (pandas-dev#9425)
  BUG: Series.align resets name when fill_value is specified
  BUG: GroupBy.get_group raises ValueError when group key contains NaT
  Close mysql connection in TestXMySQL to prevent tests freezing
  BUG: plot doesnt default to matplotlib axes.grid setting (pandas-dev#9792)
  ...
yarikoptic added a commit to neurodebian/pandas that referenced this issue Jul 2, 2015
* commit 'v0.16.1-97-gbc7d48f': (56 commits)
  disable some deps on 3.2 build
  Fix meantim typo
  DOC: use current ipython in doc build
  PERF: write basic datetimes faster pandas-dev#10271
  TST: fix for bottleneck >= 1.0 nansum behavior, xref pandas-dev#9422
  add numba example to enhancingperf.rst
  BUG: SparseSeries constructor ignores input data name
  BUG: Raise TypeError only if key DataFrame is not empty pandas-dev#10126
  ENH: groupby.apply for Categorical should preserve categories (closes pandas-dev#10138)
  DOC: add in whatsnew/0.17.0.txt
  DOC: move whatsnew from 0.17.0 -> 0.16.2
  BUG:  Holiday(..) with both offset and observance raises NotImplementedError pandas-dev#10217
  BUG: Index.union cannot handle array-likes
  BUG: SparseSeries.abs() resets name
  BUG: Series arithmetic methods incorrectly hold name
  ENH: Don't infer WOM-5MON if we don't support it (pandas-dev#9425)
  BUG: Series.align resets name when fill_value is specified
  BUG: GroupBy.get_group raises ValueError when group key contains NaT
  Close mysql connection in TestXMySQL to prevent tests freezing
  BUG: plot doesnt default to matplotlib axes.grid setting (pandas-dev#9792)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants