I have a script that plots a Fourier series using stem(). I know that I can fill the circle at the end of the stems with stem( , 'fill'). However I would like it to only fill the circle if the magnitude is negative, or alternatively, fill all of them, but have an outer circle of another color on those that have a negative magnitude.
I tried using a variable inside stem(), and also a full if-else statement, but both returned errors.
Any way this can be done?
You can remove marker from stem plot with 'Marker' property set to 'none'. Then add markers where ever you like with plot or scatter function. Add hold on after the stem command and hold off after all plotting commands.
For example:
x = randn(20,1);
stem(x,'Marker','none')
hold on
plot(find(x>0),x(x>0),'ro')
plot(find(x<0),x(x<0),'bx')
hold off
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With