Skip to content

DEPR: sort_columns in plot #47563

Closed
@PorcelainMouse

Description

@PorcelainMouse

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 numpy as np
import pandas as pd
df1 = pd.DataFrame({
    'a' : np.random.normal(0,1,10),
    'b' : np.random.normal(0,1,10),
)}
df1[['b','a']].plot.box(sort_columns=True)
df1[['b','a']].sort_index(axis=1).plot.box()

Issue Description

Best I can tell, this option just doesn't work. The documentation describes the result of this option as "Sort column names to determine plot ordering." It is clear this means ordering the columns by name, presumably lexically. But, instead, this is what it does:
bug_python_sort

Expected Behavior

I interpret this option to be equivalent to .sort_index(axis=1), which works.

bug_python_sort_workaround

Installed Versions

INSTALLED VERSIONS

commit : e8093ba
python : 3.10.5.final.0
python-bits : 64
OS : Linux
OS-release : 5.18.6-200.fc36.x86_64
Version : #1 SMP PREEMPT_DYNAMIC Wed Jun 22 13:46:18 UTC 2022
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.utf8
LOCALE : en_US.UTF-8

pandas : 1.4.3
numpy : 1.22.0
pytz : 2022.1
dateutil : 2.8.1
setuptools : 59.6.0
pip : 21.3.1
Cython : 0.29.26
pytest : 6.2.5
hypothesis : None
sphinx : 4.4.0
blosc : 1.10.6
feather : None
xlsxwriter : 3.0.3
lxml.etree : 4.7.1
html5lib : 1.1
pymysql : 1.0.2
psycopg2 : None
jinja2 : 3.0.3
IPython : 8.3.0
pandas_datareader: 0.10.0
bs4 : 4.11.0
bottleneck : 1.3.2
brotli : 1.0.9
fastparquet : 0.8.1
fsspec : 2022.5.0
gcsfs : 2022.5.0
markupsafe : 2.0.0
matplotlib : 3.5.2
numba : None
numexpr : 2.8.1
odfpy : None
openpyxl : 3.0.10
pandas_gbq : None
pyarrow : 8.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.8.1
snappy : None
sqlalchemy : 1.4.39
tables : 3.7.0
tabulate : 0.8.10
xarray : 2022.3.0
xlrd : 2.0.1
xlwt : 1.3.0
zstandard : None

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions