Adding sigstar to grouped bar graph
15 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I have sets of data that is being compared within each group. However, I need to display all of the groups on one graph so I can show how differences compare across various participants. Right now, this is the graph that I have. I would like to add sigmas between various blue, red, yellow bars depending of the results of the individual participant. Does anyone know how I could possible do that?
Thank you for your time!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1741041/image.png)
0 commentaires
Réponses (1)
Star Strider
le 26 Juil 2024 à 0:32
I am not certtain what you are asking, and you did not post your MATLAB release. (Itt would help to have your datta, the code you already wrote to process it, and what you want it ttto do.)
If you want to add error bars to the bars, that is straightforward —
Data = randi(9, 4, 3);
err = rand(size(Data));
figure
hb = bar(Data);
hold on
for k = 1:size(Data,2)
xc = hb(k).XEndPoints;
yc = hb(k).YEndPoints;
errorbar(xc, yc, err(:,k), '.k', 'MarkerSize',0.1)
end
hold off
.
2 commentaires
Star Strider
le 26 Juil 2024 à 1:05
My pleasure!
O.K. That is a variation of the error bar approach.
Try this —
Data = randi(9, 4, 3);
err = rand(size(Data));
figure
hb = bar(Data);
hold on
for k = 1:size(Data,2)
xc = hb(k).XEndPoints;
yc = hb(k).YEndPoints;
errorbar(xc, yc, err(:,k), '.k', 'MarkerSize',0.1)
end
bw = hb(1).BarWidth;
xc(1,:) = hb(1).XEndPoints;
xc(2,:) = hb(end).XEndPoints;
yc(1,:) = hb(1).YEndPoints;
yc(2,:) = hb(end).YEndPoints;
xcr = xc(:,1) + [-bw; bw]/4;
ycr = max(yc(:,1));
plot(xcr, [1 1]*ycr*1.5, '-k', 'LineWidth',3)
plot(mean(xcr), ycr*1.6, '*k', 'MarkerSize',15)
hold off
Make appropriatte changes to get the result you want.
.
Voir également
Catégories
En savoir plus sur Histograms dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!