MATLAB: Legend for scatter plot has lines through markers

legendmarkers

Hi, I am creating a scatter plot that uses different markers, which I access from a vector. When I add a legend to the plot, these markers show up correctly, but there is a line through them, which I would like to remove.
Here is a simple example. If you create the following plot, you will get what you would expect. A legend with just the marker symbol next to the label 'Case 1'. plot(1,1,'*'); legend('Case 1');
However, if you create a plot in the following manner (see below), the legend will now have a line through that marker. I'm wondering if there is a way to remove or turn-off that line? I need to do this latter approach since I am plotting multiple points in a scatter plot, and accessing different markers using a vector of symbols.
plot(1,1,'marker','*'); legend('Case 1');
Thanks!

Best Answer

The third argument in plot sets the line style and markerstyle. If you do not specify a 3rd argument then plot assigns a line per default. If you use your second option, then you add a marker to the already existing line and you have to change the linestyle after plotting.
h=plot([1],[1],'marker','*');
legend('Case 1');
set(h,'linestyle','none')