How to plot 2 discrete plots (each of a different colour) with stem ?

6 vues (au cours des 30 derniers jours)
jefazo jefazo
jefazo jefazo le 16 Oct 2020
Modifié(e) : Adam Danz le 16 Oct 2020
Hi,
I am trying to use stem to plot a discretised cos and sine waves on a same plot but every point is having a different colour. I want my sine wave points to be of a same colour (e.g. red) and my cos wave points to be of another colour (e.g. blue). Does someone know how to fix this ? Thanks in advance.
plots=[a; b];
time=[t;t]; %Same amount of time for both waves so both have the same vector t
stem(time,graphs);

Réponses (1)

Adam Danz
Adam Danz le 16 Oct 2020
Modifié(e) : Adam Danz le 16 Oct 2020
h = stem(time,graphs) will return a vector of handles. Then set their color using
h(1).Color = 'b';
h(2).Color = 'r';
If that doesn't solve the problem, please provide more details on the size of "time" and "graphs".

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by