Matlab – Change Line Width of Plot of Fit in Matlab

MATLABmatlab-figureplot

I'd like to change the width of my fit plot along the lines of:

plot(fit, 'LineWidth', WidthSpec)

Unfortunately, when I try plotting the data and fit simultaneously like:

plot(fit, 'LineWidth', WidthSpec, XData, YData)

I get an error message saying

??? Error using ==> cfit.plot at 52
EXCLUDEDATA has greater length than XDATA.

Plotting both without specification of the width like

plot(fit, XData, YData) 

works just fine.

Best Answer

Try to store the returned handle and adjust the width using that:

h = plot(fit, ...);
set(h, 'LineWidth',2)