How to change only the LineStyle of the top curve?

1 回表示 (過去 30 日間)
Mohammad
Mohammad 2019 年 12 月 17 日
編集済み: Adam Danz 2019 年 12 月 18 日
I'm trying the following code (Mathworks example) but I only want the LineStyle of top curves to be as specified (like the attached figure). Also I want the xaxis strats from 0 instead of 1.
Y = [1, 5, 3;
3, 2, 7;
1, 5, 3;
2, 6, 1];
figure
area(Y, 'Linewidth', 2, 'LineStyle', '-.')

回答 (1 件)

Adam Danz
Adam Danz 2019 年 12 月 17 日
編集済み: Adam Danz 2019 年 12 月 18 日
Here are two options with slightly different outcomes.
Option 1
Modify the upper line only
Y = [1, 5, 3;
3, 2, 7;
1, 5, 3;
2, 6, 1];
figure()
area(Y)
hold on
plot(sum(Y,2),'Linewidth', 2, 'LineStyle', '-.')
Option 2
Modify the line that surrounds the entire outline of the upper area object.
Y = [1, 5, 3;
3, 2, 7;
1, 5, 3;
2, 6, 1];
figure()
h = area(Y); % get the area object handles
set(h(3), 'Linewidth', 2, 'LineStyle', '-.')

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by