Question
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?
Expert Answer
Prashant Kumar
PhD Expert
Answered Sep 1, 2026
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.
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related plot linewidth Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →