how to change the Line width in stem

fouad fouad · Oct 31, 2022 · 2K views
Question
each time i want to use stem option, i see just circles without lines and i need to change the line width from 0.5 to 1   % n=0:4; x=2*n; stem(n,x); in the figure i go to view>>property editor>> i click on the circle in the graph>> i change the line width from 0.5 to 1 and the lines apeares again is there a way to change the default value of the line width to 1 without changing it each time. thanks for your help.
Expert Answer
Profile picture of John Williams
John Williams PhD Expert
Answered Aug 24, 2026
I am not certain it is possible to set default (for example, groot) properties for stem plots without affecting all other line series plots. It does not seem so from the documentation.
 
You might contact MathWorks to see if such an option exists, but I would be surprised if it does.
 
If you use stem a lot and do not want to set the properties each time, consider creating your own stem function.
 
Example:
function hs = MyStem(x,y)
hs = stem(x,y, 'LineWidth',1)
end

Save it as a function file. Then just call your MyStem function as you otherwise would call stem. In this example, it also returns the handle if you want it to, so you can set the other parameters, such as axis labels, title, and others from your script.

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

Get a Free Consultation or a Sample Assignment Review!