Skip to content
Snippets Groups Projects

[Matlab] Bar with errors

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Amaury Guillermin
    barWithErrors.m 425 B
    function barWithErrors(x, y, err, legends)
        b = bar(x, y);
        
        hold on
        % Calculate the number of groups and number of bars in each group
        [ngroups,nbars] = size(y);
        % Get the x coordinate of the bars
        xi = nan(nbars, ngroups);
        for i = 1:nbars
            xi(i,:) = b(i).XEndPoints;
        end
        errorbar(xi', y, err,'k','linestyle','none');%Adding the errorbars
        hold off
        
        legend(legends);
    end
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment