1
votes

I am plotting some discrete values with a stem plot in MATLAB. I found that if the value is zero, the stem plot will put a circle on the x axis to show the zeros. Is there a way to have a stem NOT showing the circles if the value is zero?

1

1 Answers

4
votes

Treat them as NaN's, ie:

Y = [1;2;3;0;3;2;4;0;1];
Y(Y == 0) = NaN;
stem(Y);

The 4th and 8th index will still exist on the x-axis, but if the observation is set to NaN, no line or circle will be plotted.