-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
BUG: df.plot(kind='barh') does not show xlabel #46129
Comments
As described in official doc:
It seems that the default rule of Dataframe.plot takes precedence, causing xlabel not to be displayed. There is a way to temporarily solve this problem by using the plt library directly. co2.plot.barh()
plt.title('CO₂ Tübingen to Berlin')
plt.xlabel('kg CO₂-eq')
plt.show() The xlabel will show up on the x-axis. |
Hi! I tried this example in the main branch and found that the xlabel issue has been fixed. Pls check PR 45145, which sloves ur xlabel problem. |
Hi, @McToel ! I find that Pandas plot uses common processing logic: It converts data into DataFrame for subsequent operations, meaning that a Series with name=None will change into DF with columns=["None"]. (By default, the value will changed to That is why
I tried to solve the I'll keep working on it, but before that, I wonder if dealing with Series and DataFrame separately is a step backwards. |
I would suggest to just replace |
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
The code produces the following plot, with the xlabel showing up on the y-axis.

When only supplying the ylabel, everything works as expected.
When supplying both, the xlabel overrides the ylabel
Expected Behavior
The xlabel should show up on the x-axis.
Installed Versions
INSTALLED VERSIONS
commit : 06d2301
python : 3.9.10.final.0
python-bits : 64
OS : Linux
OS-release : 5.13.0-30-generic
Version : #33~20.04.1-Ubuntu SMP Mon Feb 7 14:25:10 UTC 2022
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.4.1
numpy : 1.22.0
pytz : 2020.1
dateutil : 2.8.1
pip : 22.0.3
setuptools : 58.1.0
Cython : 0.29.21
pytest : 6.2.5
hypothesis : None
sphinx : 3.4.3
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.6.2
html5lib : None
pymysql : None
psycopg2 : 2.8.6
jinja2 : 2.11.2
IPython : 7.19.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
fsspec : 0.8.4
gcsfs : None
matplotlib : 3.5.1
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 6.0.1
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.7.3
sqlalchemy : 1.3.24
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None
The text was updated successfully, but these errors were encountered: