Skip to content
This repository was archived by the owner on Apr 5, 2019. It is now read-only.

Commit b42e726

Browse files
committed
Respect previous hold state of parentaxes
1 parent 354a35e commit b42e726

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

legtools.m

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,21 @@ function adddummy(lh, newStrings, plotParams)
204204
% TODO: More plotParams error checking
205205

206206
parentaxes = lh.PlotChildren(1).Parent;
207-
hold(parentaxes, 'on');
207+
208+
% Hold parent axes
209+
if ishold(parentaxes)
210+
washold = true;
211+
else
212+
washold = false;
213+
hold(parentaxes, 'on');
214+
end
215+
208216
for ii = 1:length(newStrings)
209217
plot(parentaxes, NaN, ...
210218
plotParams{ii}{:}, ... % Leave validation up to plot
211219
'UserData', 'legtools.dummy')
212220
end
213-
hold(parentaxes, 'off');
221+
if ~washold, hold(parentaxes, 'off'); end
214222

215223
legtools.append(lh, newStrings); % Add legend entries
216224
end % of adddummy method

0 commit comments

Comments
 (0)