How to set a new default linewidth for stem plots

조회 수: 11 (최근 30일)
Benedikt Beckenbauer
Benedikt Beckenbauer 2021년 9월 7일
댓글: Mathieu NOE 2021년 9월 7일
Hey,
I want to set a new default LineWidth for my stem-plots, so every new stem plot will be plotted with a LineWidth of '2'.
set(0,'defaultLineLinewidth',2)
The code line above only changes the LineWidth of continuous plots.
Thank you!
  댓글 수: 4
Benedikt Beckenbauer
Benedikt Beckenbauer 2021년 9월 7일
Thanks! I saw that too, but this won't allow me to use for example different line styles for the stem plots. I thought there's a way to set a default settings defining a additional function.
Mathieu NOE
Mathieu NOE 2021년 9월 7일
hello
FYI, we can further expand @Star Strider 's idea ( his credit)
% 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

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

답변 (1개)

KSSV
KSSV 2021년 9월 7일
x = rand(1,5) ;
h = stem(x) ;
h.LineWidth
ans = 0.5000
h.LineWidth = 2 ;

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by