0

As it is now , my median line is showing but I am not so sure why the value of the median line displayed is not in correctly plotted on the y-axis. For example , my median is 1.4 and another box plot's median is 2.4. However , the median line for 2.4 is below the median line 1.4 so it is not ordered correctly as it should be higher than the previous median line.

enter image description here

Code:

boxplot1=plt.boxplot(data,labels=labelling,patch_artist=True,widths =  0.7)

boxplot1['boxes'][0].set_facecolor('cyan')
boxplot1['boxes'][1].set_facecolor('moccasin')  
boxplot1['boxes'][2].set_facecolor('turquoise')  
boxplot1['boxes'][3].set_facecolor('coral')
boxplot1['boxes'][4].set_facecolor('khaki') 



for line in boxplot1['medians']:

    x, y = line.get_xydata()[1]
    
    plt.text(x, y, '%.1f' % x,
         horizontalalignment='center') 

plt.show()         
Mr. T
  • 11,960
  • 10
  • 32
  • 54

0 Answers0