linewidth for specific line
6 次查看(过去 30 天)
显示 更早的评论
how to specify linewidth for one line in a multi line plot?
1 个评论
Ahmer Ashraf
2020-2-23
I'm bound on linewidth property..I'm completing my assignment but this property is not going me forward.
采纳的回答
John BG
2017-1-7
编辑:John BG
2017-1-7
Noam
I kindly ask to have the following answer marked as Accepted Answer:
x = 1:1:10;
L=5 % amount of lines
y = randi([1 10], L,10);
Lwidth=[1 2 3 4 5]
figure(1);hold all
for k=1:1:L
plot(x,y(k,:),'LineWidth',Lwidth(k))
end
grid on
or
figure(1);hold all
for k=1:1:L
h=plot(x,y(k,:))
h.LineWidth=Lwidth(k)
end
grid on

.
appreciating time and attention
John BG
4 个评论
John BG
2017-1-7
Dear Start Strider, here no one has plagiarised your answer.
Your answer has a constant line width of 2.
The question is asking for a variable line width.
I supply an answer that has a variable line width: 5 lines with different LineWidth parameters.
do you see the difference?
Star Strider
2017-1-7
There is no essential difference!
My Answer shows how to do what Noam wants to do. It should be easy for Noam to use my code and expand on it as necessary. ‘Multiline’ implies more than one line, and my code does exactly what was asked.
更多回答(1 个)
Star Strider
2017-1-6
Use the hold function and plot them individually:
x = 1:10;
y1 = rand(1, 10);
y2 = 1+rand(1,10);
figure(1)
plot(x, y1)
hold on
plot(x, y2, 'LineWidth',2)
hold off
grid
2 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!