Skip to content

BUG: df.plot(kind='barh') does not show xlabel #46129

Closed
@McToel

Description

@McToel

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

import pandas as pd
import matplotlib.pyplot as plt

co2 = pd.Series({
    'train': 4.8,
    'car': 128.5,
    'aiplane': 98.5
})

co2.plot(
    kind='barh',
    title='CO₂ Tübingen to Berlin',
    xlabel='kg CO₂-eq'
)

plt.show()

Issue Description

The code produces the following plot, with the xlabel showing up on the y-axis.
image

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions