horizontal boxplot with data dots on it and different colors

could some one creat a matlab code for horizontal boxplot with data dots on it and different colors for 2 groups? similar to attached

3 comentarios

I when i change my plot to horizontal the dots on it, disapeared and only visible on one of the boxes. change the following to horizontal and compare with the original.
%% Learning rate
clc; clear all; close all
y1 = [1.06 1.1 0.89 0.96 0.95 1 0.76 1.41 0.97 0.75 0.83 0.76 0.79 1.31 1.08 0.83]';
y2 = [1.16 1.07 1.13 1 1.01 1 0.87 1.42 1.26 0.86 0.95 0.9 1.02 1.22 1.19 0.86]';
y3 = [1.2 1.15 1.16 0.97 1.14 1 0.98 1.14 1.51 0.93 1.03 0.9 1 1.28 1.39 0.93]';
allData = {y1; y2; y3};
group = [ ones(size(y1));
2 * ones(size(y2))
3 * ones(size(y3))];
h = boxplot(cell2mat(allData),group), title('Learning Rate Across Different Memory Load','FontSize',20);
h = 7×3
10.0074 17.0073 24.0073 11.0073 18.0073 25.0073 12.0073 19.0073 26.0073 13.0073 20.0073 27.0073 14.0073 21.0073 28.0073 15.0073 22.0073 29.0073 16.0073 23.0073 30.0073
set(h, 'linewidth' ,2)
%% FontSize has been reduced to get a proper view of the figure
set(gca,'XTickLabel', {'2 Letters'; '4 Letters'; '6 Letters'},'FontSize',12)
ylabel('Response Time (Seconds)','FontSize',12);
hold on
xCenter = 1:numel(allData);
spread = 0.5; % 0=no spread; 0.5=random spread within box bounds (can be any value)
for i = 1:numel(allData)
plot(rand(size(allData{i}))*spread -(spread/2) + xCenter(i), allData{i}, 'mo','linewidth', 2)
end
When you change the orientation, do you want to change the xticks, yticks, xlabel and ylabel as well?

Iniciar sesión para comentar.

 Respuesta aceptada

%% Learning rate
clc; clear all; close all
y1 = [1.06 1.1 0.89 0.96 0.95 1 0.76 1.41 0.97 0.75 0.83 0.76 0.79 1.31 1.08 0.83]';
y2 = [1.16 1.07 1.13 1 1.01 1 0.87 1.42 1.26 0.86 0.95 0.9 1.02 1.22 1.19 0.86]';
y3 = [1.2 1.15 1.16 0.97 1.14 1 0.98 1.14 1.51 0.93 1.03 0.9 1 1.28 1.39 0.93]';
allData = {y1; y2; y3};
group = [ ones(size(y1));
2 * ones(size(y2))
3 * ones(size(y3))];
h = boxplot(cell2mat(allData),group,'Orientation','horizontal'), title('Learning Rate Across Different Memory Load','FontSize',20);
h = 7×3
10.0015 17.0002 24.0002 11.0012 18.0002 25.0002 12.0006 19.0002 26.0002 13.0004 20.0002 27.0002 14.0002 21.0002 28.0002 15.0002 22.0002 29.0002 16.0002 23.0002 30.0002
set(h, 'linewidth' ,2)
%% FontSize has been reduced to get a proper view of the figure
set(gca,'YTickLabel', {'2 Letters'; '4 Letters'; '6 Letters'},'FontSize',12)
xlabel('Response Time (Seconds)','FontSize',12);
hold on
xCenter = 1:numel(allData);
spread = 0.5; % 0=no spread; 0.5=random spread within box bounds (can be any value)
for i = 1:numel(allData)
plot(allData{i}, rand(size(allData{i}))*spread -(spread/2) + xCenter(i), 'mo','linewidth', 2)
end

Más respuestas (0)

Categorías

Más información sobre Data Distribution Plots en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 11 de Oct. de 2023

Respondida:

el 31 de Oct. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by