Skip to content

Categories reordered to alphabetical when plotting histograms #29235

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

Closed
dmey opened this issue Oct 26, 2019 · 0 comments · Fixed by #33336
Closed

Categories reordered to alphabetical when plotting histograms #29235

dmey opened this issue Oct 26, 2019 · 0 comments · Fixed by #33336
Labels
Categorical Categorical Data Type Visualization plotting

Comments

@dmey
Copy link

dmey commented Oct 26, 2019

Code Sample, a copy-pastable example if possible

import pandas as pd

import matplotlib.pyplot as plt

df = pd.DataFrame({
    'width': [0.7, 0.2, 0.15, 0.2, 1.1],
    'length': [1.5, 0.5, 1.2, 0.9, 3]
    }, index= ['pig', 'rabbit', 'duck', 'chicken', 'horse'])

# Whether or not `column` is passed the order is still reordered to alphabetical.
df.hist(column=['width','length'])
plt.show()

Problem description

When plotting histograms from a DataFrame (see code-snippet above) the order of subplots is not maintained. Passing column does not appear to have any effect on the ordering either.

Expected Output

Plots/subplots order equals column order in DataFrame.

Output of pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 3.7.3.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 69 Stepping 1, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None

pandas: 0.24.2
pytest: 5.2.1
pip: 19.1.1
setuptools: 41.0.1
Cython: None
numpy: 1.16.4
scipy: 1.2.2
pyarrow: None
xarray: 0.12.1
IPython: 7.5.0
sphinx: None
patsy: 0.5.1
dateutil: 2.8.0
pytz: 2019.1
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 3.1.0
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml.etree: None
bs4: 4.7.1
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10.1
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Categorical Categorical Data Type Visualization plotting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants