From 19904da43879173e2c04490c132d4e692eabad7e Mon Sep 17 00:00:00 2001 From: Olivier Sauter <olivier.sauter@epfl.ch> Date: Tue, 11 Jun 2024 09:59:38 +0200 Subject: [PATCH] fix legend to add on to linehandles if multiple shots --- matlab/gdat_plot.m | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/matlab/gdat_plot.m b/matlab/gdat_plot.m index 8fa184d1..29895699 100644 --- a/matlab/gdat_plot.m +++ b/matlab/gdat_plot.m @@ -40,10 +40,12 @@ if doplot==0; return; end redo_legend_from_Tags = 0; do_legend = 1; +nb_linehandles_current = numel(linehandles); for ishot=1:numel(gdat_data) + nb_linehandles_prev = nb_linehandles_current; if all(isfield(gdat_data(ishot),{'data','t'})) && ~isempty(gdat_data(ishot).data) && ~isempty(gdat_data(ishot).t) fighandle = get(0,'CurrentFigure'); - if numel(gdat_data) > 1 && gdat_data(1).gdat_params.doplot==1 + if ishot > 1 && gdat_data(1).gdat_params.doplot==1 % assume that for a series of shot, need doplot=-1 after 1st plot if doplot was 1 in request doplot = -1; end @@ -161,12 +163,13 @@ for ishot=1:numel(gdat_data) zoom on; end maxnblines = 1; + nb_linehandles_current = numel(linehandles); if ~exist('ab','var'), ab=get(gca,'children'); end if do_legend==0 || redo_legend_from_Tags || any(strcmp(gdat_data(ishot).gdat_params.data_request,'powers')) ... || (numel(ab)==numel(gdat_data(ishot).label) && numel(ab)>1) % keep legend as is else - for i=1:numel(linehandles) + for i=nb_linehandles_prev+1:nb_linehandles_current maxnblines = max(maxnblines,numel(linehandles{i})); if numel(linehandles{i}) == 1 set(linehandles{i},'DisplayName',[num2str(gdat_data(ishot).shot)]); -- GitLab