Change inter quartile range(IQR) for boxchart
16 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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,
my problem is similor to this https://stackoverflow.com/questions/27962191/matlab-boxplot-use-a-specific-percentile-as-the-upper-whisker-or-remove-redunda but with the boxchart.
Can I get any help?
0 comentarios
Respuestas (1)
Jaynik
el 2 de Abr. de 2024
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!
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!