I am trying to create boxplot from pandas dataframe using matplotlib.
I am able to get the boxplot and change the linewidth of outlines and median lines, but I would like to change all the colors to black. I tried several ways as described in Pandas boxplot: set color and properties for box, median, mean and Change the facecolor of boxplot in pandas.
However, none of them worked for my case.
Could someone solve these problems?
Here are my codes:
version: python 3.6.5
import pandas as pd
from pandas import DataFrame, Series
import matplotlib.pyplot as plt
df = pd.read_excel("training.xls")
fig = plt.figure()
ax = fig.add_subplot(111)
boxprops = dict(color="black",linewidth=1.5)
medianprops = dict(color="black",linewidth=1.5)
df.boxplot(column=["MEAN"],by="SrcID_Feat",ax=ax,
boxprops=boxprops,medianprops=medianprops)
plt.grid(False)
Result