How can the ConstantLine LineWidth property default be set?

Using
set(groot,'defaultConstantLineLineWidth',2)
should set the ConstantLine's LineWidth default property to 2, but it gives the following error:
Error using matlab.ui.Root/set
constantlinelinewidth is an invalid class name
How can this default property be set?
This property would affect the vertical line drawn by xline(), for example:
x=[1:10];
y=x.^2;
plot(x,y);
xline(4);
I am following this resource

댓글 수: 2

I'm guessing that your matlab release is prior to r2018b which is when the constantLine objects were released.
I am using R2018b. The ConstantLine property is displayed when
get()
is used on the axes handle, but for some reason using
set(groot,'defaultConstantLineLineWidth',2)
does not affect this property.

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

 채택된 답변

Adam Danz
Adam Danz 2020년 1월 13일
편집: Adam Danz 2020년 1월 13일

0 개 추천

After looking more closely as your code, I realized you're using a property that doesn't exist "defaultConstantLineLineWidth"; nor does "defaultConstantLineWidth".
Perhaps you mean defaultLineLineWidth.

댓글 수: 3

godruler
godruler 2020년 1월 13일
편집: godruler 2020년 1월 13일
No, this will not affect the line drawn by xline() or yline(). What is odd is that when you run get() on the axes handle you can see the "ConstantLine" type and its associated property "LineWidth". But for some reason this property does not exist when it comes to setting it's default with groot.
That's correct, and an unfortunate inconsistancy. In fact, I'll report this to the tech team and suggest that it's changed in future releases.
Update: Case Number 03967262
To reproduce the inconsistancy, the code below sets the default line width to 6 and produces a line object and constantLine object, both of which have LineWidth properties, but only the line object is affected by the default setting.
set(groot,'defaultLineLineWidth',6)
cla()
plot([1 1],[0,1],'-')
h = xline(0.5);
xlim([0,1.5])
Thank you for looking into this Adam.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Integration with Online Platforms에 대해 자세히 알아보기

질문:

2020년 1월 13일

편집:

2020년 1월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by