horizontal boxplot with data dots on it and different colors
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Dyuman Joshi
2023-10-11
When you change the orientation, do you want to change the xticks, yticks, xlabel and ylabel as well?
采纳的回答
Voss
2023-10-31
%% 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);
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
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Distribution Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!