Skip to content

BUG: Horizontal boxplots on subplots throws ValueError #36918

Closed
@H-SG

Description

@H-SG
  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


Code Sample, a copy-pastable example

import pandas as pd
import numpy as np

df1 = pd.DataFrame(np.random.randint(0,100,size=(100, 4)), columns=list('ABCD'))
df2 = pd.DataFrame(np.random.randint(0,100,size=(100, 4)), columns=list('ABCD'))

f, axs = plt.subplots(1, 2, figsize=(10,7), sharey=True)
df1.boxplot(ax=axs[0], showfliers=False, vert=False)
df2.boxplot(ax=axs[1], showfliers=False, vert=False)

Problem description

Above code snippet throws ValueError: The number of FixedLocator locations (8), usually from a call to set_ticks, does not match the number of ticklabels (4). due to changes introduced in matplotlib 3.3.0.

It looks like fixes were implemented as part of #35393 in boxplot.py for vert=True but not for vert=False. Performing the len(ticks) != len(keys) check for ticks = ax.get_yticks() and the associated keys list doubling snippet fixes the issue.

Not sure if that is the right fix, but works for my use case.

Expected Output

Two sets of horizontal boxplot charts

Output of pd.show_versions()

INSTALLED VERSIONS

commit : 2a7d332
python : 3.7.3.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-48-generic
Version : #52-Ubuntu SMP Thu Sep 10 10:58:49 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.1.2
numpy : 1.19.2
pytz : 2020.1
dateutil : 2.8.1
pip : 19.1.1
setuptools : 41.0.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.5.2
html5lib : None
pymysql : None
psycopg2 : 2.8.6 (dt dec pq3 ext lo64)
jinja2 : 2.11.2
IPython : 7.18.1
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.3.2
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : 1.5.2
sqlalchemy : 1.3.19
tables : None
tabulate : None
xarray : None
xlrd : 1.2.0
xlwt : None
numba : None

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions