Errorbar: change line width of marker line, not of error bars
조회 수: 32 (최근 30일)
이전 댓글 표시
Hello everyone,
I plotted multiple lines with their errorbars using the following function:
errorbar(angle,mw,stdev);
However, with some lines and errorbars in one plot, this gets a bit messy. What I wanted to do, is to highlight the "main marker line" (the "mw" values so to say) to make them stand out a bit more. But if I do it via "LineWidth", the main line plus errorbar becomes bigger. Is there a way to exlude the errorbars?
Thank you in advance!
댓글 수: 0
채택된 답변
sloppydisk
2018년 5월 7일
편집: sloppydisk
2018년 5월 7일
Unfortunately the errorbar data type does not have any children you can edit directly. I would probably do something like this as a workaround:
angle = rand(20, 1);
mw = 1:20;
stdev = .1*ones(20, 1);
errorbar(mw, angle,stdev, 'LineStyle', 'None');
hold on
plot(mw, angle, 'LineWidth', 3);
hold off
댓글 수: 2
Loc Q. Huynh
2022년 6월 25일
What if I want to add the legend after that? In my case, I have 2 arrays and the legend showed 4 set of data instead of 1.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1045425/image.png)
추가 답변 (1개)
Zhuohe Liu
2023년 4월 14일
Actually, you may control separately the cap, bar and line style using hidden properties. For example, as I tested in r2023a. However, the legend icon might need to be changed separately.
figure
e = errorbar([1, 2], [1, 2], [0.5, 0.6], 'DisplayName', 'Demo');
e.Cap.LineWidth = 1;
e.Bar.LineWidth = 1;
e.Line.LineWidth = 2;
xlim([0, 3]);
legend('show')
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Errorbars에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!