From 4e85d3e766f2aed5dff46c14a47868731fc5499d Mon Sep 17 00:00:00 2001 From: Olivier Sauter <Olivier.Sauter@epfl.ch> Date: Mon, 31 Jan 2022 17:30:10 +0100 Subject: [PATCH] minor fix of gdat_plot --- matlab/gdat_plot.m | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/matlab/gdat_plot.m b/matlab/gdat_plot.m index d2a1edeb..ccbf80d0 100644 --- a/matlab/gdat_plot.m +++ b/matlab/gdat_plot.m @@ -38,6 +38,7 @@ elseif isfield(gdat_data,'gdat_params') && isfield(gdat_data.gdat_params,'doplot end if doplot==0; return; end redo_legend_from_Tags = 0; +do_legend = 1; if all(isfield(gdat_data,{'data','t'})) && ~isempty(gdat_data.data) && ~isempty(gdat_data.t) fighandle = get(0,'CurrentFigure'); @@ -63,6 +64,7 @@ if all(isfield(gdat_data,{'data','t'})) && ~isempty(gdat_data.data) && ~isempty( eval(['linehandles{end+1} = plot(gdat_data.eqdsk' endstr '.rlim,gdat_data.eqdsk' endstr '.zlim,''k'');']) axis equal; title(eval(['gdat_data.eqdsk' endstr '.stitle'])); + do_legend = 0; elseif any(find(size(gdat_data.data)==length(gdat_data.t))) try if length(size(gdat_data.data))<=2 @@ -154,8 +156,10 @@ if all(isfield(gdat_data,{'data','t'})) && ~isempty(gdat_data.data) && ~isempty( zoom on; end maxnblines = 1; - if redo_legend_from_Tags || any(strcmp(gdat_data.gdat_params.data_request,'powers')) || (numel(ab)==numel(gdat_data.label) && numel(ab)>1) - % keep legend from label + if ~exist('ab','var'), ab=get(gca,'children'); end + if do_legend==0 || redo_legend_from_Tags || any(strcmp(gdat_data.gdat_params.data_request,'powers')) ... + || (numel(ab)==numel(gdat_data.label) && numel(ab)>1) + % keep legend as is else for i=1:numel(linehandles) maxnblines = max(maxnblines,numel(linehandles{i})); @@ -168,7 +172,7 @@ if all(isfield(gdat_data,{'data','t'})) && ~isempty(gdat_data.data) && ~isempty( end end end - if maxnblines==1; legend show; end + if do_legend==1 && maxnblines==1; legend show; end if strcmp(gdat_data.gdat_request,'mhd') % special case, add legend instead of ylabel delete(hylabel); -- GitLab