Skip to content

Commit

Permalink
Improved the legend_add function
Browse files Browse the repository at this point in the history
  • Loading branch information
ezander committed Sep 27, 2017
1 parent 2da013f commit e7e8b56
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions plotting/legend_add.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,7 @@ function legend_add( text )
end

% Get the strings from the existing legend and add the new string
[h,~,~,text_strings] = legend();
if isempty(text_strings) && isobject(h)
% Try to work around a bug in R2015b. don't use the returned legend handle
% from the legend() call, it is not necessary and leads to errors in newer
% matlab version (>R2014b))
if isempty(h)
text_strings = {};
else
text_strings = h.String(:)';
end
end
h = legend();
text_strings = get(h, 'String');

legend( [text_strings, {text}] );

0 comments on commit e7e8b56

Please sign in to comment.