Search code examples
matlabplotmatlab-figureerrorbar

Color of errobar different from the graph matlab


i have this problem i want to make a color of errobars different from the color of my graph there is the code i have tried

pp=errorbar(x,testMatriceFluxSortie/ValeurFluxSortie(1,1),err)
pp.Color=[255 0 1]./255;

But it gives me this all in red my graph


Solution

  • you can always use hold on and plot only the x,y data after the errorbar was plotted, for example:

    x = 1:10:100;
    y = [20 30 45 40 60 65 80 75 95 90];
    err = 8*ones(size(y));
    
    errorbar(x,y,err,'or'); hold on
    plot(x,y,'b');
    

    enter image description here