Change stem colour of particular values

19 ビュー (過去 30 日間)
Nikolas Spiliopoulos
Nikolas Spiliopoulos 2021 年 7 月 3 日
コメント済み: Star Strider 2021 年 7 月 3 日
Hi there,
I have a stem plot with 66 points and I would like to change the colour of particular valuesonly.
Mpre specifically I want to pur green colour to the 39th, 53rd and 59th element of the graph.
Can you hepl me with that? i have seen similar questions but didn't manage to find a proper solution
thanks a lot!

採用された回答

Star Strider
Star Strider 2021 年 7 月 3 日
Try something like this —
x = 1:10;
y = rand(size(x));
figure
stem(x, y)
hold on
stem(x([1 3 5]),y([1 3 5]),'g', 'MarkerEdgeColor','b')
hold off
grid
It changes the stem colour to green, and keeps the marker colour blue.
It is also possible to change the other properties of the chosen (and other) stems and markers.
.
  2 件のコメント
Nikolas Spiliopoulos
Nikolas Spiliopoulos 2021 年 7 月 3 日
thanks a lot!
Star Strider
Star Strider 2021 年 7 月 3 日
As always, my pleasure!

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

その他の回答 (1 件)

Chunru
Chunru 2021 年 7 月 3 日
x = (1:66);
y = randn(1, 66); % your data
figure; hold on
stem(x, y, 'r');
i1 = [39 53 59];
stem(x(i1), y(i1), 'g');

カテゴリ

Help Center および File ExchangeDescriptive Statistics and Visualization についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by