How do i make a specific thing on a bar graph
1 view (last 30 days)
Show older comments
Sorry for the unspecific title I don't know the name of the thing I need help creating in matlab, as such I can't look it up online. Could someone please tell me what the lines circled in Red are called and how I would add them to a bar graph? thank you for your help!
0 Comments
Accepted Answer
Mehmed Saad
on 15 May 2020
Edited: Mehmed Saad
on 15 May 2020
You can use line for that purpose. See this link
You can also use errorbar
V = [8 18 32];% Bar Value
x = [1.5 2.5 2];% errorbar x cord
y= [25 37 45];% errorbar y cord
e = [0.5 0.5 1];% errorbar error
p_val = {'p=0.037','p<0.0001','p<0.0001'};% strings
figure,bar(V,'LineWidth',1.5,'FaceColor',[0.7843 0.7843 0],'BarWidth',0.6)
ylim([0 50]),xlim([0.5 3.5]);
hold on,errorbar(x,y,e,'horizontal','LineWidth',2,'Color','k','LineStyle','none')
ax =gca;
text(x,y,p_val,'BackgroundColor',get(gca,"Color"),'HorizontalAlignment','center')
set(ax,'Linewidth',2,'FontSize',15,'FontWeight','bold','Ytick',0:10:40,'XTickLabel',{'A','B','C'})
0 Comments
More Answers (0)
See Also
Categories
Find more on Errorbars in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!