Use the two object handles to set their respective properties--although legend does inherit axes properties such as the linewidth from its parent axis which makes a certain amount of sense.
hAx=gca;
hL=plot(randn(5,1));
hAx.LineWidth=2;
hLg=legend('A');
hLg.LineWidth=1;
Presuming hobj is the handle of the figure or returned by whichever function used to plot in the axes, hl above is the line in the graph equivalent to hL above. Setting 'LineWidth' for that object changes the linestyle of the line itself, not the same property at all as the axes. And, changing it will change the line characteristics in both as the legend reflects the characteristics of the associated line in the axes to which it belongs. That is a builtin connection that is immutable without trickery to create secondary lines such that the connection between which legend entry is shown and the given line is disguised by creating hidden objects or similar.
Best Answer