I wonder if there is any real difference between two following versions of 'hold on' application:
- Case 1 – 'hold on' is used directly after the 'figure' declaration
- Case 2 – 'hold on' is used after the first plot
% DATA
x = 1:10;y1 = x.^2;y2 = x.^3;% PLOTS
% Case 1 - 'hold on' after 'figure' declaration
figurehold on;plot(x, y1);plot(x, y2);% Case 2 - 'hold on' after 1st plot
figureplot(x, y1);hold on;plot(x, y2);
- Is there any performance gain/loss between these two cases?
- Or it is entirely down to the preference of the person writing the code?
I'm asking as I noticed that many people use 'Case 1' style, which I personally find more elegant. but on the other hand, all the examples featured in the Matlab documentation use the 'Case 2' style.
To add a bit more into the mix, I came across this thread, where Jan Simon abstains from using 'hold on' function altogether in favour of using handles:
So, what is the 'best practice' in this regard?
Best Answer