Series.plot should label y axis with Series name
See original GitHub issueCode Sample, a copy-pastable example if possible
import pandas as pd
import matplotlib.pyplot as plt
ind = pd.Series(['first', 'second', 'third'], name='count')
s = pd.Series([1, 2, 3], index=ind, name='i should be a y label')
s.plot()
plt.show()
Problem description
So when you call Series.plot, xlabel is set to the name of the index, but ylabel is not set to the name of the series itself. To me it seems asymmetric and believe it should set ylabel automatically.
Also, if I plot it with s.plot(kind='hist')
, I get ylabel “Frequency” but no xlabel, which I would expect to be the name of the series as well.
Expected Output
ylabel set to name of the series for usual plot, and xlabel set to name of the series for hist plot
Output of pd.show_versions()
[paste the output of pd.show_versions()
here below this line]
INSTALLED VERSIONS
commit: None python: 3.6.2.final.0 python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: AMD64 Family 16 Model 4 Stepping 3, AuthenticAMD byteorder: little LC_ALL: None LANG: None LOCALE: None.None
pandas: 0.20.3 pytest: 3.2.1 pip: 9.0.1 setuptools: 36.5.0.post20170921 Cython: 0.26.1 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.999999999 sqlalchemy: 1.1.13 pymysql: None psycopg2: None jinja2: 2.9.6 s3fs: None pandas_gbq: None pandas_datareader: None
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (3 by maintainers)
Top GitHub Comments
Actually, I made my workaround even more convenient. I just have this snippet at the start of my python notebook, and then I can use Series.plot in ordinal way, but it now puts ylabel as I wanted.
So, I’m entirely satisfied with this so I close the issue.
@yudai-nkt I don’t think you are doing something wrong, your exact code piece worked flawlessly for me back in the days. I haven’t been using pandas for a while and not exactly sure how it can be fixed for newer version.
As a suggestion, you can put a breakpoint before
kargs[0].__dict__
line and see what is inside and change the code accordingly. And yeah, all of this is fiddling with internal data structures and such structure probably can be changed even in minor releases as it is not part of public API.