필터 지우기
필터 지우기

Change inter quartile range(IQR) for boxchart

조회 수: 16 (최근 30일)
Bhaskar R
Bhaskar R 2021년 12월 6일
답변: Jaynik 2024년 4월 2일
Hi,
I had to use only boxchart for my application where I need to change Inter Quartile Range(IQR) from default range i.e 25% for the lower and 75% is the upper quartiles respectly. I see changing of IQR in boxplot using the Outliers Tag box object possible, but for the boxchart there is no much help found in different forums.
As from the help of boxchart, it is using quantile Algorithms where the upper quartile corresponds to the 0.75 quantile and the lower quartile corresponds to the 0.25 quantile defauly, I have statisticas and machine learning toolbox,
Can I get any help?

답변 (1개)

Jaynik
Jaynik 2024년 4월 2일
Hi Bhaskar,
From the given description, it seems like you want to add whiskers to a custom value of IQR instead of the default. As per my understanding, this is not directly possible with the 'boxchart' function. Here is a possible workaround that adds the custom whiskers to the initial plot:
% Assuming that data stores your data
bc = boxchart(data);
% Adding custom whiskers:
lowerPercentile = 0.3; % 30th percentile
upperPercentile = 0.7; % 70th percentile
% Calculate custom percentiles
customBounds = quantile(data, [lowerPercentile, upperPercentile]);
ax = gca;
hold on;
xPos = 1;
yLower = customBounds(1);
yUpper = customBounds(2);
% Plot lines for custom percentiles
% Adjust x-coordinates based on your data structure and boxchart layout
plot(ax, [xPos-0.4, xPos+0.4], [yLower, yLower], '--r');
plot(ax, [xPos-0.4, xPos+0.4], [yUpper, yUpper], '--r');
hold off;
This script calculates and plots lines representing custom whiskers at the 30th and 70th percentiles. It is important to note that this approach visually marks the custom whiskers without altering the box itself.
Hope this helps!

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by