필터 지우기
필터 지우기

How to get different sizes of horizontal and vertical error bars?

조회 수: 4 (최근 30일)
Vaishali
Vaishali 2024년 1월 9일
편집: Star Strider 2024년 1월 9일
So I have to put error bars for both horizontal and vertical but I have different x-axis and y-axis scale so my horizontal error bar is too tiny. How do I change the length of the horizontal error bar ? Thank you for advance for helping. Hve a nice day !
err_1 = 0.1*ones(size(Error_c1));
err_2 = 0.1*ones(size(Error_c2));
err_3 = 0.1*ones(size(Error_c3));
err_4 = 0.1*ones(size(Error_c4));
errorbar(aoa,Lift_c1,err_1,"both");
errorbar(aoa,Lift_c2,err_2,"both");
errorbar(aoa,Lift_c3,err_3,"both");
errorbar(aoa,Lift_c4,err_4,"both");

답변 (1개)

Star Strider
Star Strider 2024년 1월 9일
One option would be to use:
axis equal
or:
axis('equal')
There is no obvious way to scale them otherwise.
  댓글 수: 2
Vaishali
Vaishali 2024년 1월 9일
Thank you for answering. The difference is too much to make the axis equal :( Is there no other way?
Star Strider
Star Strider 2024년 1월 9일
편집: Star Strider 2024년 1월 9일
My pleasure!
The easiest way to determine the plot data aspect ratio is to use the daspect function. You can uyse this information to scale the shorter error bar lengths to be proportional to the longer error bar lengths. (I do not have enough information from your initial post to determine how best to do this in your specific situation.)
Getting that information is relatively straightforward —
xv = linspace(0, 10, 100);
yv = 100*exp(-0.25*xv) .* sin(2*pi*xv/1.5);
errx = rand(size(xv));
erry = rand(size(yv));
figure
errorbar(xv, yv, errx, errx, erry, erry)
grid
xlabel('X')
ylabel('Y')
title('Original')
figure
hp = plot(xv, yv); % Plot Original Data To Get Aspect Ratio Of Plot
m = daspect; % Aspect Ratio
sr = m(2)/m(1); % SCaling Ratio
hold on
errorbar(xv, yv, errx*sr, errx*sr, erry, erry, 'Color',hp.Color) % Plot 'errorbar' With Scaled X-Errors
hold off
grid
xlabel('X')
ylabel('Y')
title('Scaled Error Bars')
Experiment with this with your data to get the result you want. You can apply the ‘scaling ratio’ to either set of error bars.
EDIT — Corrected typographical errors.
.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by