How to plot x and y error bars together with the data points?

42 ビュー (過去 30 日間)
Vitalie Lungu
Vitalie Lungu 2021 年 10 月 17 日
編集済み: Scott MacKenzie 2021 年 10 月 17 日
Hello! I am new to MATLAB and I am kinda stuck on a simple problem.
Let's suppose I have the data points x=[x1,x2,...,xn], y=[y1,y2,...,yn] and the uncertainties coresponding to these values error_x=[xe1,xe2,...,xen], error_y=[ye1,ye2,...,yen]. How could I plot the data together with the error bars?
This is an example how the data points would like:
Thanks!

採用された回答

Scott MacKenzie
Scott MacKenzie 2021 年 10 月 17 日
編集済み: Scott MacKenzie 2021 年 10 月 17 日
Something like this seems to work:
% test data
x = randi([2 8],1,5);
y = randi([2 8],1,5);
error_x = rand(1,5);
error_y = rand(1,5);
scatter(x,y, 'd', 'filled');
set(gca, 'xlim', [0 10], 'ylim', [0 10]);
hold on;
errorbar(x, y, error_x, error_x, 'linestyle', 'none', 'color', 'k', 'linewidth', .8);
errorbar(x, y, error_y, error_y, 'horizontal', 'linestyle', 'none', 'color', 'k', 'linewidth', .8);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Object Identification についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by