Change width on fitted line in function fitlm
14 views (last 30 days)
Show older comments
Vlatko Milic on 21 Nov 2019
Commented: dpb on 22 Nov 2019
I can't change the witdh on a fitted line based on X number of data points when I use fitlm-function. I am only able to change the width of the data points themselves.
Do you have any ideas?
The code is:
Kind regards, Vlatko
dpb on 21 Nov 2019
Yeah, save the handles returned by plot for the linear model fit...
You can find this out by returning the handle array from plot and see that it is a four-handle array...and example here was
>> load carsmall % MATLAB sample data set
>> lm=fitlm(MPG,Weight); % fit a simple model
>> hLM=plot(lm) % plot it, return handles array
4×1 Line array:
Line (Confidence bounds)
>> hLM(2).LineWidth % the fit is the second handle in the arrray; query it
>> hLM(2).LineWidth=1; % set it to new value
dpb on 22 Nov 2019
set(hLM(3:4),'LineWidth',1); % set both confidence lines same time
See doc set for details...
More Answers (0)
Find more on Fit Postprocessing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!