how to change the Line width in stem

조회 수: 12 (최근 30일)
fouad fouad
fouad fouad 2016년 12월 10일
댓글: Mathieu NOE 2021년 9월 7일
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.
  댓글 수: 2
Star Strider
Star Strider 2016년 12월 10일
Why not just do this?
n=0:4;
x=2*n;
stem(n,x, 'LineWidth',1)
fouad fouad
fouad fouad 2016년 12월 10일
편집: fouad fouad 2016년 12월 10일
i need to know the problem and solve it because i use "stem" a lot so i d'ont want to write it each time.
i hope to find a way to change the default value to its original state 1
thank you anyway

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2016년 12월 10일
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.
  댓글 수: 1
Mathieu NOE
Mathieu NOE 2021년 9월 7일
Good idea , can be expanded to even more parameters
% dummy data
x=0:4;
y=2*n;
% MyStem parameters
par.LineStyle = '--'; % Use one of these values: '-' |'--' | ':' | '-.' | 'none'.
par.LineWidth = 2;
par.Marker = '*';
par.MarkerSize = 8;
par.MarkerFaceColor = 'none';
hs = MyStem(x,y,par);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function hs = MyStem(x,y,par)
hs = stem(x,y, 'LineStyle',par.LineStyle, 'LineWidth',par.LineWidth, 'Marker',par.Marker, 'MarkerSize',par.MarkerSize, 'MarkerFaceColor',par.MarkerFaceColor)
end

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Title에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by