How to change the line thickness inside the legend box ?
126 次查看(过去 30 天)
显示 更早的评论
采纳的回答
Adam Danz
2020-4-13
编辑:Adam Danz
2020-4-13
The line properties of the legend components cannot be changes independently from the line objects they represent in the plot. So, the easiest solution is to change the line properties from within the plot.
h = plot(x,y, 'LineWidth', 1.5);
% or
h.LineWidth = 1.5;
If you want the change the legend representation without changing the line property, you can copy the line and replace its XData and YData with NaN values so it doesn't appear in the plot. Then you can change it's LineWidth property and create the legend using the new line's handle.
ax = axes();
hold on
h = plot(x,y, 'b-o');
hLeg = copyobj(h, ax);
set(hLeg, 'XData', NaN, 'YData', NaN, 'LineWidth', 1.5)
legend(hLeg)
12 个评论
Farzad Torabi
2023-1-22
Please use a new post to discuss this post to avoid unwanted comments. Many thanks!
Adam Danz
2023-1-23
@Farzad Torabi, you can unfollow this thread to stop getting notifications. Click the "unfollow" button under the title of your question.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1271725/image.png)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Legend 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!