Why can't I make a boxplot with data overlay?

Here we go... So, I have the following boxplot, the values on the X-axis are spaced by 1, which is fine and I understand why, but I need to find a way to do the same boxplot, but with each box at its own value and scale even if there is box overlaps. Is there a way to do this?

 Akzeptierte Antwort

How about using a boxchart ?
The following is an example:
% Sample data
x = [ones(100,1); 2*ones(100,1); 4*ones(100,1)];
y = rand(300,1)+x;
% Draw box plot for each x-value position
figure
boxchart(x,y)

8 Kommentare

Brenno Selli
Brenno Selli am 20 Okt. 2023
I tryed it a few days ago but the plot goes blank...
Akira Agata
Akira Agata am 20 Okt. 2023
Seems strange. If possible, could you upload your data?
Brenno Selli
Brenno Selli am 20 Okt. 2023
Of course I can Mr Akira, I will attach the data for a test simulation... "pfs" are the 36 values ​​placed on the x-axis and "MEDIA_A_HB" are the values ​​associated with the y-axis when I plot.
The first column of pfs is associated with the first column of MEDIA_A_HB and so on..
Brenno Selli
Brenno Selli am 20 Okt. 2023
Here it is
OK.
To create the expected boxchart, you have to use boxchart function with "boxchart(xgroupdata, ydata)" style.
Please use the following as a reference:
% Load data
s = load('mr_akira_files.mat');
pfs = s.pfs;
MEDIA_A_HB = s.MEDIA_A_HB;
% Create "xgroupdata"
pfs2 = repelem(pfs', 10, 1);
% Cleare boxchart (box width is adjusted)
figure
boxchart(pfs2, MEDIA_A_HB(:),...
"BoxWidth", 0.1)
Brenno Selli
Brenno Selli am 20 Okt. 2023
Wow... Okay, now it appears to be working really well. I expected results exactly as plotted.
Thank you very much Mr Akira, I'll plot for more data and if this becomes an article, you will certainly be in the thanks section. Thank you so much.
Voss
Voss am 20 Okt. 2023
@Brenno Selli: You can thank @Akira Agata now by clicking the Accept button on his answer.
Akira Agata
Akira Agata am 23 Okt. 2023
@Brenno Selli: It's my pleasure! :-)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Data Distribution Plots finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by