Skip to content

Error bars not rendered correctly #17467

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

Closed
drorata opened this issue Sep 7, 2017 · 4 comments · Fixed by #23674
Closed

Error bars not rendered correctly #17467

drorata opened this issue Sep 7, 2017 · 4 comments · Fixed by #23674
Labels
Milestone

Comments

@drorata
Copy link
Contributor

drorata commented Sep 7, 2017

Code Sample, a copy-pastable example if possible

From the /doc/source/visualization.rst:

import pandas as pd
import matplotlib.pyplot as plt

# Generate the data
ix3 = pd.MultiIndex.from_arrays([['a', 'a', 'a', 'a', 'b', 'b', 'b', 'b'], ['foo', 'foo', 'bar', 'bar', 'foo', 'foo', 'bar', 'bar']], names=['letter', 'word'])
df3 = pd.DataFrame({'data1': [3, 2, 4, 3, 2, 4, 3, 2], 'data2': [6, 5, 7, 5, 4, 5, 6, 5]}, index=ix3)

# Group by index labels and take the means and standard deviations for each group
gp3 = df3.groupby(level=('letter', 'word'))
means = gp3.mean()
errors = gp3.std()
means
errors

# Plot
fig, ax = plt.subplots()
means.plot.bar(yerr=errors, ax=ax)

Problem description

The resulting image doesn't contain the horizontal ticks of the error bars.

figure_1

Expected Output

figure_1

To achieve this the last line should be replaced with

means.plot.bar(yerr=errors, ax=ax, capsize=4)

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.6.2.final.0
python-bits: 64
OS: Darwin
OS-release: 16.7.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.20.3
pytest: 3.2.1
pip: 9.0.1
setuptools: 27.2.0
Cython: 0.26
numpy: 1.13.1
scipy: 0.19.1
xarray: None
IPython: 6.1.0
sphinx: 1.6.3
patsy: 0.4.1
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: 1.2.1
tables: 3.4.2
numexpr: 2.6.2
feather: None
matplotlib: 2.0.2
openpyxl: 2.4.8
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 0.9.8
lxml: 3.8.0
bs4: 4.6.0
html5lib: 0.999
sqlalchemy: 1.1.13
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
pandas_gbq: None
pandas_datareader: None

@justinchan23
Copy link
Contributor

I will take a stab at this!

@TomAugspurger
Copy link
Contributor

I don't recall perfectly, but I think in in #17468 I expressed concern with deviating from the matplotlib default style.

@dat-boris
Copy link
Contributor

Thanks @TomAugspurger !

Ah in #17468 - we saw an issue of unrelated code getting pulled in and thought that's why the PR was aborted. Thanks for the extra context.

So to summarize from #17468 there are a few suggestions:

From @TomAugspurger 👍

, Either way, I think aesthetically the version without caps looks better. What do you think?

From @drorata

As for the aesthetic aspect --- I think the caps are crucial for faster and better perception of the error bars.

I'm really dont want to get back into the "passionate" debate about error cap as have others previously done in matplotlib/matplotlib#5047 😅

I am happy if this goes either way - I think there's pros and cons on both sides as already demonstrated as in the above discussion.

Although I do have a slight preference in demonstrating that capability in the documentation.

My thought is that it helps to show an example of capsize keyword argument and allow a developer to choose the right way to go. I don't think the documentation is representative of suggested styling.

Let's decide and either:"

  1. close this issue
  2. merge the PR?

Thank you!
Boris

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Nov 13, 2018 via email

@jreback jreback added this to the 0.24.0 milestone Nov 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants