From 0b93a17eebfb20e830f3b6a7b721cc39f7bc9a76 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer <jpfeifer@gmx.de> Date: Thu, 8 Sep 2022 15:28:31 +0200 Subject: [PATCH] plot: do not try to reset xTickLabel based on new dates if hold on was used --- src/@dseries/plot.m | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/@dseries/plot.m b/src/@dseries/plot.m index 93a9859..b10c866 100644 --- a/src/@dseries/plot.m +++ b/src/@dseries/plot.m @@ -58,12 +58,20 @@ switch ndseries id = get(gca,'XTick'); if isequal(id(1),0) dates = strings([o.dates(1)-1,o.dates(id(2:end))]); + skip_relabeling=0; else ID = id(find(isint(id))); - set(gca,'XTick',ID); - dates = strings(o.dates(ID)); + if any(ID<o.dates(1).double) || any(ID>o.dates(end).double) + skip_relabeling=1; %hold on was used so that axis tight did not restrict current xlim to dseries used. + else + set(gca,'XTick',ID); + dates = strings(o.dates(ID)); + skip_relabeling=0; + end + end + if ~skip_relabeling + set(gca,'XTickLabel',dates); end - set(gca,'XTickLabel',dates); case 2 [o0, o1] = align(o, varargin{1}); if isequal(nvariables,1) -- GitLab