-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Horizontal boxplots on subplots throws ValueError #36918
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
Comments
@H-SG PR is welcome! |
Hello, I have also looked into this. The problem rises when So for example, if I have got two subplots with 3 vertical boxplots each and I do not know if this is a bug or intended behaviour, but anyway now matplotlib wants the precise number of ticks, and so if we pass a list of 3 items to The author of #35393 already found out this issue and, for the xaxis, he worked around this problem by replicating the same labels by the number of subplots (but not for the yaxis, therefore why it fails as it is pointed out in this issue). However, if we take the slightly modified example that he posted, the behaviour of matplotlib looks still buggy to me:
Matplotlib 3.1.1: Matplotlib 3.3.2: Note that in matplotlib 3.3.2, the same letters are drawn twice. However, if we use So I think that, in order to solve this issue in pandas, one of these two things could be done:
Let me know what you think, I can do a PR if needed Edit: spelling |
sure! @francibm97 the issue hasn't been taken, feel free to take it and PR is very welcomed!! |
@charlesdong1991 ok nice I'll implement one of the two proposed solutions and create a PR |
take |
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
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
forvert=True
but not forvert=False
. Performing thelen(ticks) != len(keys)
check forticks = 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
The text was updated successfully, but these errors were encountered: