lines through markers on legend
19 次查看(过去 30 天)
显示 更早的评论
I am having a plot but on the legend, there are no lines through the markes. How can I fix this?.
The structure of the code is as follows:
x=-10:0.1:10;
y=cos(x);
plot(x,y,'--o','MarkerSize',5,'DisplayName',' cos(x)')
hold on
y=sin(x)
plot(x,y,'--d','MarkerSize',5,'DisplayName',' sin(x)')
hold off
legend
grid on
3 个评论
Star Strider
2020-8-7
This might have already been fixed.
Be certain you have installed all the Updates. On the top toolstrip, click Help then Check for Updates.
回答(2 个)
madhan ravi
2020-8-7
x = -10 : 0.1 : 10;
y = cos(x);
plot(x, y, '--o', 'MarkerSize', 5)
hold on
y = sin(x)
plot(x, y, '--d', 'MarkerSize', 5)
hold off
legend({'cos(x)', 'sin(x)'})
grid on
3 个评论
Arthur Roué
2020-8-7
You specified '--' option for your line style in 3rd argument of plot. If you want full lines, use '-' instead.
x=-10:0.1:10;
y=cos(x);
plot(x,y,'-o','MarkerSize',5,'DisplayName',' cos(x)')
hold on
y=sin(x)
plot(x,y,'-d','MarkerSize',5,'DisplayName',' sin(x)')
hold off
legend
grid on
3 个评论
Arthur Roué
2020-8-7
I do have lines in the legend with previous code. Seems like your MATLAB is not working correctly...
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Legend 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!