is it a bug?
1 view (last 30 days)
The code below
(i) does not produce an error message about not matching x and y; it can be explained by implicit expansion in plot();
(ii) produces 100 legends; this I cannot explain.
Steven Lord on 11 Sep 2019
If you call plot with an output argument to return handles to any lines that are created, you'll see that 100 individual lines get created, one per point.
h = plot(x,y,'DisplayName','a bug');
That's also why your legend has 100 entries, one per line that plot created.
If you're using release R2018b or later and you want to display a horizontal line stretching the whole width of the axes, use yline.
More Answers (1)
Bruno Luong on 11 Sep 2019
Edited: Bruno Luong on 11 Sep 2019
No it's not a bug: from PLOT doc
- If one of X or Y is a scalar and the other is either a scalar or a vector, then the plot function plots discrete points. However, to see the points you must specify a marker symbol, for example, plot(X,Y,'o').
You get really 100 points plotted.