BUG: Boxplots are ignoring xlabel · Issue #45463 · pandas-dev/pandas (original) (raw)

Pandas version checks

Reproducible Example

import pandas as pd

df = pd.DataFrame( {'a': [2, 1, 4, 5, 1, 5], 'b': [4, 3, 5, 5, 2, 1]} ) df.plot(kind='box', xlabel='x', ylabel='y') df.plot(kind='box', xlabel='x', ylabel='y', vert=False) df.boxplot(xlabel='x', ylabel='y')

Issue Description

Results for the above snippet show that xlabel is ignored in both cases:

Screen Shot 2022-01-18 at 7 42 34 PM

Screen Shot 2022-01-18 at 7 43 39 PM

The final command raises an error:


TypeError Traceback (most recent call last) /var/folders/2x/099whkgd0n99mrmnk__zzyr80000gp/T/ipykernel_17452/1525097035.py in ----> 1 df.boxplot(xlabel='x', ylabel='y')

~/Desktop/pandas/pandas/plotting/_core.py in boxplot_frame(self, column, by, ax, fontsize, rot, grid, figsize, layout, return_type, backend, **kwargs) 509 ): 510 plot_backend = _get_plot_backend(backend) --> 511 return plot_backend.boxplot_frame( 512 self, 513 column=column,

~/Desktop/pandas/pandas/plotting/_matplotlib/boxplot.py in boxplot_frame(self, column, by, ax, fontsize, rot, grid, figsize, layout, return_type, **kwds) 423 import matplotlib.pyplot as plt 424 --> 425 ax = boxplot( 426 self, 427 column=column,

~/Desktop/pandas/pandas/plotting/_matplotlib/boxplot.py in boxplot(data, column, by, ax, fontsize, rot, grid, figsize, layout, return_type, **kwds) 402 data = data[columns] 403 --> 404 result = plot_group(columns, data.values.T, ax) 405 ax.grid(grid) 406

~/Desktop/pandas/pandas/plotting/_matplotlib/boxplot.py in plot_group(keys, values, ax) 336 keys = [pprint_thing(x) for x in keys] 337 values = [np.asarray(remove_na_arraylike(v), dtype=object) for v in values] --> 338 bp = ax.boxplot(values, **kwds) 339 if fontsize is not None: 340 ax.tick_params(axis="both", labelsize=fontsize)

~/miniconda3/envs/test/lib/python3.9/site-packages/matplotlib/init.py in inner(ax, data, *args, **kwargs) 1359 def inner(ax, *args, data=None, **kwargs): 1360 if data is None: -> 1361 return func(ax, *map(sanitize_sequence, args), **kwargs) 1362 1363 bound = new_sig.bind(ax, *args, **kwargs)

TypeError: boxplot() got an unexpected keyword argument 'xlabel'

Expected Behavior

Screen Shot 2022-01-18 at 7 44 56 PM

Installed Versions

INSTALLED VERSIONS

commit : bc2a383
python : 3.9.6.final.0
python-bits : 64
OS : Darwin
OS-release : 20.6.0
Version : Darwin Kernel Version 20.6.0: Tue Oct 12 18:33:42 PDT 2021; root:xnu-7195.141.8~1/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.4.0.dev0+1695.gbc2a383c76.dirty
numpy : 1.20.3
pytz : 2021.1
dateutil : 2.8.2
pip : 21.2.4
setuptools : 52.0.0.post20210125
Cython : 0.29.25
pytest : 6.2.5
hypothesis : 6.29.3
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.6.3
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.0.2
IPython : 7.29.0
pandas_datareader: 0.10.0
bs4 : None
bottleneck : 1.3.2
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.4.2
numba : None
numexpr : 2.7.3
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.7.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None