フィルターのクリア

using fill function to make shaded area

12 ビュー (過去 30 日間)
Ham Man
Ham Man 2022 年 11 月 1 日
コメント済み: Ham Man 2022 年 11 月 2 日
Hi every one!
Is it possible to draw a shaded area (e.g., +- STD of a value) when we have a categorical values on x-axis?
Based on the screenshot I want AA,BB,CC instead of the numbers.(dash line is a value and the shaded area around it can be plus/minus STD)
Many thanks.

採用された回答

Walter Roberson
Walter Roberson 2022 年 11 月 2 日
x = categorical({'AA', 'BB', 'CC'});
yraw = rand(50,3);
ymean = mean(yraw,1);
plot(x, ymean, 'b');
s = std(yraw, [], 1);
hold on
fill([x, fliplr(x)], [ymean-s, fliplr(ymean+s)], 'k', 'FaceAlpha', 0.1 )
hold off
  4 件のコメント
Walter Roberson
Walter Roberson 2022 年 11 月 2 日
Use reordercats to get the order the way you want. The default order is alphanumeric, and dp1200 is before dp500 because the comparison proceeds from the beginning and '1' is before '5'
would it be possible to start a bit before AA and ends a bit after CC
You would need to add additional categories -- for example if you wanted to start 1/10 before AA you would need 32 or so categories in which AA was the 2nd category, CC was the 31'st category, and BB was the middle. And you would probably need to use xticks([AA, BB, CC]) so you got ticks at the right place.
The alternative would be to switch to a numeric axes instead of a categorical axes, and use xticks() to place the marks numerically and xlabels() to write in the appropriate category names.
Ham Man
Ham Man 2022 年 11 月 2 日
Thank you so much Walter. That works.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by