Hey together,
I have the following code:
maxDisp = 0;
nPoints = 21;
nEntries = 12;
formatIn = 'dd.mm.yyyy';
cc = jet(nPoints);
figure('Name','Test','NumberTitle','off');
for i = 1:nPoints
hold on
errorbar(MP{i}(:,1),[0; MP{i}(2:end,12)]/10,...
[0; MP{i}(2:end,nEntries + 1)]/10,'color',cc(i,:))
if max(MP{i}(:,12)) > maxDisp
maxDisp = max(MP{i}(:,12));
end
end
grid on
datetick('x',formatIn)
xticks(axisTicks(1:2:end));
xticklabels(datestr(axisTicks(1:2:end),formatIn))
xtickangle(45)
axis([datenum("01.01.1989",formatIn) today 0 75])
giving me the image:
I'd like to get the lines stopping at the axis (so not to overlay the axis). But I can't find a way to do so. Anyone knowing how to get the things to look proper?
Find the matrices needed attached.
As Alex Mcaulley mentions it seems to be an issues only appearing within some versions of Matlab, mine is R2018a.

1 commentaire

Alex Sune
Alex Sune le 31 Mai 2019
Your code works as you want in my release (R2016b)
figure.png

Connectez-vous pour commenter.

Réponses (1)

Star Strider
Star Strider le 31 Mai 2019

0 votes

You may have turned off the 'Clipping' (link) property of the axes.
Try this:
set(gca, 'Clipping','on')

2 commentaires

Turning on the 'Clipping' option did not work for me. However I found a not so nice but working option by modifiying the loop as follows
for i = 1:nPoints
hold on
errorbar(MP{i}(:,1),[0; MP{i}(2:end,12)]/10,...
[0; MP{i}(2:end,nEntries + 1)]/10,'color',cc(i,:))
plot(MP{i}(:,1),[0; MP{i}(2:end,12)]/10,'color',cc(i,:))
if max(MP{i}(:,12)) > maxDisp
maxDisp = max(MP{i}(:,12));
end
end
Like this the plot is overlaying the errorbar which generates correctly the borders. It's no nice solution but at least a solution....
Star Strider
Star Strider le 31 Mai 2019
What MATLAB version (release) are you using?
It’s probably worthwhile to ask MathWorks to see if an easier option exists. (Use the Contact Us (telephone handset icon) link in the upper right corner of this page.) If so, post the MathWorks solution as a separate Answer. I will then delete my Answer, since it didn’t solve your problem.

Connectez-vous pour commenter.

Catégories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by