I would like to draw a boxplot
figure using matplotlib
.
And this is the code to generate the figure:
pt = plt.boxplot(all_data, sym='+')
plt.yticks([0, 0.2, 0.4, 0.6, 0.8, 1.0], ['0', '20%', '40%', '60%', '80%', '100%'])
plt.xticks([y + 1 for y in range(len(all_data))], ['WMC', 'DIT', 'CBO', 'RFC', 'LCOM', 'Ca', 'NPM'])
mean = []
for line in pt['medians']:
x, y = line.get_xydata()[1] # top of median line
plt.text(x, y, '%.1f' % x,
horizontalalignment='center') # draw above, centered
plt.savefig("boxplot1.pdf")
A box in a boxplot shows the 1st, 2nd and 3rd quartiles (Q1, the median and Q3) of a dataset. For each box, there is a line (which is also called a whisker and whose length is 1.5*IQR (inter quartile range) by default). So basically what I am looking for is instead of using the default value, explicitly set the lower and upper limits (or the whisker length) to a certain value I specify.
Could anyone shed some lights on this?