Skip to content
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

color attribute of medianprops is not correctly understand in a boxplot #30346

Closed
gVallverdu opened this issue Dec 19, 2019 · 4 comments · Fixed by #31262
Closed

color attribute of medianprops is not correctly understand in a boxplot #30346

gVallverdu opened this issue Dec 19, 2019 · 4 comments · Fixed by #31262
Assignees
Labels

Comments

@gVallverdu
Copy link

Code Sample, a copy-pastable example if possible

df = pd.DataFrame({k: np.random.random(100) for k in "ABC"})

# wrong output
df.boxplot(medianprops=dict(color="C1", lw=2))

# right output
plt.boxplot(df.transpose(), medianprops=dict(color="C1", lw=2))

Problem description

The problem comes from the boxplot function in a dataframe. This function is linked to the matplotlib function. I got an issue when I try to change the color of the medians using the medianprops argument of the function (which is a matplotlib argument). If I use the same instruction directly with the boxplot function in matplotlib I got the right behavior. But, I can change the linewidth or linestyle for example.

Here I put a screenshot of what I obtain if I use the boxplot method from pandas or directly from matplotlib. You can see that using the matplotlib function, the color of the median line is "correct" (the one I asked) while you cannot change the color of the line from the pandas function.

Capture d’écran 2019-12-19 à 11 04 32

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit : None python : 3.7.4.final.0 python-bits : 64 OS : Darwin OS-release : 19.0.0 machine : x86_64 processor : i386 byteorder : little LC_ALL : None LANG : fr_FR.UTF-8 LOCALE : fr_FR.UTF-8

pandas : 0.25.1
numpy : 1.17.2
pytz : 2019.3
dateutil : 2.8.0
pip : 19.2.3
setuptools : 41.4.0
Cython : 0.29.13
pytest : 5.2.1
hypothesis : None
sphinx : 2.2.0
blosc : None
feather : None
xlsxwriter : 1.2.1
lxml.etree : 4.4.1
html5lib : 1.0.1
pymysql : None
psycopg2 : None
jinja2 : 2.10.3
IPython : 7.8.0
pandas_datareader: None
bs4 : 4.8.0
bottleneck : 1.2.1
fastparquet : None
gcsfs : None
lxml.etree : 4.4.1
matplotlib : 3.1.1
numexpr : 2.7.0
odfpy : None
openpyxl : 3.0.0
pandas_gbq : None
pyarrow : None
pytables : None
s3fs : None
scipy : 1.3.1
sqlalchemy : 1.3.9
tables : 3.5.2
xarray : None
xlrd : 1.2.0
xlwt : 1.3.0
xlsxwriter : 1.2.1

@TomAugspurger
Copy link
Contributor

Can you step the code to see where the keyword isn't passed through?

@gVallverdu
Copy link
Author

gVallverdu commented Dec 19, 2019

Can you said to me how do you want I do it ? You mean with pdb ?

--Return--
> <ipython-input-4-1cecc13dadef>(1)<module>()->None
-> pdb.set_trace()
(Pdb) df = pd.DataFrame({k: np.random.random(100) for k in "ABC"})
(Pdb) df.boxplot(medianprops=dict(markeredgecolor="C1", lw=3, ls="--"))
<matplotlib.axes._subplots.AxesSubplot object at 0x11a4d5a10>
(Pdb) continue

@TomAugspurger
Copy link
Contributor

Yep, that's how I would do it. We eventually call Axes.boxplot and should pass through all the extra **kwargs, but apparently some are being dropped somewhere (or perhaps overridden later on?)

@TomAugspurger TomAugspurger added the Visualization plotting label Dec 20, 2019
@charlesdong1991
Copy link
Member

take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants