How to change only the LineStyle of the top curve?

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Line Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by