MATLAB: How do i make a specific thing on a bar graph

bar graph

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!

Best Answer

  • 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;