Effacer les filtres
Effacer les filtres

How to change only the LineStyle of the top curve?

2 vues (au cours des 30 derniers jours)
Mohammad
Mohammad le 17 Déc 2019
Modifié(e) : Adam Danz le 18 Déc 2019
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', '-.')

Réponses (1)

Adam Danz
Adam Danz le 17 Déc 2019
Modifié(e) : Adam Danz le 18 Déc 2019
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', '-.')

Catégories

En savoir plus sur Colormaps dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by