change color of outlier limit in box plots

조회 수: 24 (최근 30일)
yp78
yp78 2020년 1월 3일
댓글: yp78 2020년 1월 6일
For some applications, I'd like to hide the display of outliers in a boxplot.
I managed to hide the outliers using the following options, but still struggling not to display the dashed lines.
Here is a brief discription of how I do it and the outputs so far. Any help would be highly appreciated!
figure
for i=1:6
subplot(3,2,i)
boxplot(data(i),xVariables,'DataLim', [lowerLim, upperLim],'ExtremeMode','clip','Whisker',1.5, 'symbol','')
end
currentoutput.png

채택된 답변

Akira Agata
Akira Agata 2020년 1월 4일
How about the following solution?
% Sample data
x = randn(1000,4);
% Create boxplot without outlier markers
figure
boxplot(x,'Symbol','')
% Find the target lines and set their 'LineStyle' to 'none'
h = findobj('-regexp','Tag','(Lower|Upper) (Whisker|Adjacent Value)');
set(h,'LineStyle','none')
boxplot.png
  댓글 수: 3
Akira Agata
Akira Agata 2020년 1월 6일
OK. Then, the YData of the upper- and lower-limit line objects should be [3 3] and [-3 -3], respectively, you can find these line objects by:
h = findobj('YData',[-3 -3],'-or','YData',[3 3]);
Then, you can delete these lines by
delete(h);
Or, you can set 'Visible' = 'off' for these lines by
set(h,'Visible','off');
Or, alternatively, you can set line color to 'none'
set(h,'Color','none');
yp78
yp78 2020년 1월 6일
It worked perfectly! I appreciate your help :)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by