godruler
godruler

Reputation: 31

How can the ConstantLine LineWidth property default be set?

With MATLAB R2018b, 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

Upvotes: 1

Views: 229

Answers (2)

Mefitico
Mefitico

Reputation: 1116

As a kludge, you could do something like:

x=[1:10];
y=x.^2;
plot(x,y);
hold on
plot(4*[1,1], [min(y), max(y)], 'LineWidth', 3)

Upvotes: 0

godruler
godruler

Reputation: 31

ConstantLine's LineWidth default property cannot be set in MATLAB R2018b using set(groot,'defaultConstantLineLineWidth',2) due to a known inconsistency in this release of MATLAB. See discussion.

Upvotes: 1

Related Questions