how to specify linewidth for one line in a multi line plot?

1 件のコメント

Ahmer Ashraf
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
John BG 2017 年 1 月 7 日
編集済み: John BG 2017 年 1 月 7 日

3 投票

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 件のコメント

Star Strider
Star Strider 2017 年 1 月 7 日
That is exactly the essence of my Answer.
Thank you for plagiarizing it.
Noam
Noam 2017 年 1 月 7 日
Thank you all.
For two differnt graphs in nature I prefere Strider's, for a family of graphs i'd go with BG's. I used the hold trick before and was hoping for a more elegant solution.
Noam
John BG
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
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
Star Strider 2017 年 1 月 6 日

4 投票

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 件のコメント

Noam
Noam 2017 年 1 月 6 日
Thamks
Star Strider
Star Strider 2017 年 1 月 6 日
My pleasure.
If my Answer solved your problem, please Accept it!

サインインしてコメントする。

カテゴリ

製品

タグ

質問済み:

2017 年 1 月 6 日

コメント済み:

2020 年 2 月 23 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by