필터 지우기
필터 지우기

Making boxplot after removing the outliers

조회 수: 5 (최근 30일)
Md. Moklesur Rahman
Md. Moklesur Rahman 2012년 2월 21일
댓글: jkr 2023년 8월 24일
Hi dear Steve,
I used the following code to find out and remove the outliers from my several data sets. I found the outliers and removed but while making the boxplot it still shows some outliers as circular symbols above or lower the data range in the boxplot. Would you please tell me why does this happen ?
close all; clear all; clc X = xlsread('CO-2009.xlsx'); mu = mean(X); sigma = std(X);
[n,p] = size(X); MeanMat = repmat(mu,n,1); SigmaMat = repmat(sigma,n,1); outliers = abs(X - MeanMat) > 3*SigmaMat; nout = sum(outliers); X(any(outliers,2),:) = []; boxplot(X) ylabel('CO (ppbv)') h=findobj(gca,'tag','Outliers'); set(h,'Marker','o'); title('BoxPlot for CO outliers in 2009') xlswrite('CO data without OLs_2009.xlsx',X)
Rahman

채택된 답변

Tom Lane
Tom Lane 2012년 2월 21일
A point is declared an outlier based on a comparison of its value with quartiles of the data. If you take out an outlier, you also change the data used to compute the quartiles. Other points might be declared to be outliers based on the quartiles of the remaining data. The vector x=1./(1:20)' exhibits this phenomenon.
If you just want to suppress the display of the outliers without excluding them from the quartile calculation, you could display them with an empty symbol:
boxplot(x,'symbol','')
The axis limits will also take the outliers into account, so you may want to change them if you don't like that.
  댓글 수: 2
Youngjea
Youngjea 2021년 4월 21일
Very smart answer... Thank you.
jkr
jkr 2023년 8월 24일
'symbol','' works when the boxplot is generated. However, if I select the contents of the figure to increase the line width surrounding each box for improved visibility, the outliers are depicted with blue squares. I cannot find how to remove these. Can anyone help?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by