1

I have a pandas dataframe and I am trying to create boxplot using Matplotlib. I am able to get the boxplot but it looks like styling for boxplot (color for boxplot components) is not working. I am trying to learn plotting charts but somewhat confused how all elements come together. Any guidance will be highly appreciated.

import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
fig, ax = plt.subplots(figsize=(20,6))
ax.set_title('Height Distribution')
ax.set_xlabel('PANEL')
ax.set_ylabel('Height (um)')
# Define styling for each boxplot component
medianprops = {'color': 'magenta', 'linewidth': 2}
boxprops = {'color': 'black', 'linestyle': '-'}
whiskerprops = {'color': 'red', 'linestyle': '-'}
capprops = {'color': 'green', 'linestyle': '-'}
flierprops = {'color': 'yellow', 'marker': 'x'}
concatenated_df.boxplot(ax=ax, column='HEIGHT',by=['Label'],rot=90,fontsize=15,medianprops=medianprops,
           boxprops=boxprops,
           whiskerprops=whiskerprops,
           capprops=capprops,
           flierprops=flierprops)

# Save figure
fig.savefig("filename.jpg")

Boxplot

rverma
  • 127
  • 2
  • 8
  • I don't understand, what your question is. SO is not a tutorial or discussion website, a [question should relate to a specific question](https://stackoverflow.com/help/on-topic). But [this thread](https://stackoverflow.com/questions/35160956/pandas-boxplot-set-color-and-properties-for-box-median-mean) has been suggested by user @mao which should have some hints for your problem. – Mr. T Apr 10 '18 at 08:19
  • Thank you. Suggested thread answers my question. – rverma Apr 10 '18 at 15:42

0 Answers0