Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matlab - Extract values from boxplot

Tags:

matlab

I want to extract values from built in boxplot function. In A1 there are three extra large values (1000000) while correct maximum value is 273.

a = boxplot(A1)

a =

  173.0043
  174.0028
  175.0033
  176.0027
  177.0032
  178.0027
  179.0031

I tried this but I don't what the heck are these values, these are not the outliers themself nor the index of outliers.

findobj(gcf,'tag','Outliers'); returns only 179.0031

How to extract outliers or their indexes from boxplot?

like image 830
SMUsamaShah Avatar asked Jan 18 '23 05:01

SMUsamaShah


1 Answers

BOXPLOT returns the array of handles for different graphic objects.

At default parameters (plotstyle set to outline, etc) the output is 7 x M array of handles, where M is number of boxplot groups, each having the following 7 handles:

  1. Upper Whisker
  2. lower Whisker
  3. Upper Adjacent value
  4. Lower Adjacent value
  5. Box
  6. Median
  7. Outliers

At different parameters boxplot may return different number of handles, so it's better to find what you need by tag.

To extract the data you have to access the Data property of particular object, if this property exists.

h = findobj(gcf,'tag','Outliers');

xdata = get(h,'XData');
ydata = get(h,'YData');
like image 191
yuk Avatar answered Jan 31 '23 02:01

yuk