How do I plot lines with different line widths?
조회 수: 16,913(최근 30일)
Fangjun Jiang 2011년 9월 22일
편집: MathWorks Support Team 2018년 11월 8일
To plot two lines with different line widths, you can use either of these approaches.
1. Return the two “Line” objects as an output argument from the “plot” function and then set the “LineWidth” property for each.
p = plot(x1,y1,x2,y2)
p(1).LineWidth = 5;
p(2).LineWidth = 10;
2. Use the “hold on” command to plot the two lines separately. Specify the line width by setting the “LineWidth” property a name-value pair.
Wayne King 2011년 9월 22일
Hi: You can use handles.
h = plot(x1,y1,x2,y2);
SHAILENDRA PANDEY 2020년 10월 11일
x = 1:.01:10;
y1 = sin(x);
y2 = cos(x);
p = plot(x,y1,x,y2)
Line width, specified as a positive value in points, where 1 point = 1/72 of an inch. If the line has markers, then the line width also affects the marker edges.
The line width cannot be thinner than the width of a pixel. If you set the line width to a value that is less than the width of a pixel on your system, the line displays as one pixel wide.