Hi, I want to do: plot(x1,y1,x2,y2,'LineWidth',8) but the linewidth propery ends up applying to both lines. Do I have to use two plot functions with a hold on command to have line1 a different width than line2?
Prashant Kumar answered .
2025-11-20
Yes, you will need to use two separate plot functions with the hold on command to set different line widths for each line in MATLAB. Here's an example of how you can do this:
plot(x1, y1, 'LineWidth', 2); % Set the line width for the first line
hold on; % Hold the current plot
plot(x2, y2, 'LineWidth', 8); % Set the line width for the second line
hold off; % Release the plot hold
This way, each plot command will apply the specified line width to the respective line. The hold on command ensures that both lines are plotted on the same graph.