Clear Filters
Clear Filters

Display of errorbar function in plot legend

3 views (last 30 days)
Hi
I am annoyed about a line going through the errorbar symbol in my legend. I have tried to make a dummy plot for handles, ploting it prior to all other plots with lines in them, but it does not change anything. I can not find any information about it in the documentation and I was not able to find any other treads where this was complained about and obviously not any solution either. I attached an image below since it is a bit hard to explain. Thanks a lot!
This is how I ploted the errorbar
errorbar(mean(x1),mean(y1),sdy1,sdy1,sdx1,sdx1,'k')

Answers (1)

Mann Baidi
Mann Baidi on 14 Jun 2024
I can understand that you would like to remove the line in the errorbar legend symbol.
Although I am not aware the proper solution, I have a possible workaround which might be helpful:
You can remove the 'k' parameter from the errorbar function, and set the 'LineStyle' parameter to 'None'. This will avoid plotting the line in the graph. However, if you still want to plot the line, you can use 'hold on' command in matlab and plot the line separately.
You can check to the following code for reference:
x = 1:10:100;
y = [20 30 45 40 60 65 80 75 95 90];
yneg = [1 3 5 3 5 3 6 4 3 3];
ypos = [2 5 3 5 2 5 2 2 5 5];
xneg = [1 3 5 3 5 3 6 4 3 3];
xpos = [2 5 3 5 2 5 2 2 5 5];
errorbar(x,y,yneg,ypos,xneg,xpos,'LineStyle','none')
hold on
plot(x,y)
legend({'Line_1'})

Products


Release

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!