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

29 visualizzazioni (ultimi 30 giorni)
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");

Risposte (1)

Star Strider
Star Strider il 9 Gen 2024
One option would be to use:
axis equal
or:
axis('equal')
There is no obvious way to scale them otherwise.
  2 Commenti
Vaishali
Vaishali il 9 Gen 2024
Thank you for answering. The difference is too much to make the axis equal :( Is there no other way?
Star Strider
Star Strider il 9 Gen 2024
Modificato: Star Strider il 9 Gen 2024
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.
.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by