MATLAB: Marker and Line in legend in matlab plot

legendlinesmarkersMATLAB

Hi, I am plotting the experimental data and fitted line using matlab plot. The legend command shows the markers (data points) and line (fit) as a separate legend entry. However, I am interested to obtain the marker and line in a single legend entry so that the total number of legend entries could be reduced from 8 to 4 in my case. Hence, I would like to ask your assistance which could be useful for my plot. Thank you.

Best Answer

Create additional line objects that combine the attributes, such as
LH(1) = plot(nan, nan, '*-r');
L{1} = 'tadpoles';
LH(2) = plot(nan, nan, '^:g');
L{2} = 'cheese';
Then legend() those
legend(LH, L)