79759856

Date: 2025-09-09 11:57:34
Score: 0.5
Natty:
Report link

As mentioned in the comment, you can set up a "fake" dotted line and adjust the markersize in the legend with its line width and the amount of dots with the IconColumnWidth of the legend:

yourDataX = linspace(1, 10, 100);
yourDataY = [0.35 1 3];

colors = [0.83 0.14 0.14; 1.00 0.54 0.00; 0.47 0.25 0.80];
lineWidth = 2;
iconColumnWidth = 10;

for ii = 1:3
    plot(nan,"LineStyle",":","LineWidth", lineWidth,"Color",colors(ii,:))
    hold on
    plot(yourDataX, yourDataY(ii),".","HandleVisibility","off","Color",colors(ii,:))    
end

l = legend;
l.IconColumnWidth = iconColumnWidth;
l.NumColumns = 3;

That gives you this:

Legend has more dots.

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Till