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

Alex Sune
Alex Sune 2019년 5월 31일
Your code works as you want in my release (R2016b)
figure.png

댓글을 달려면 로그인하십시오.

답변 (1개)

Star Strider
Star Strider 2019년 5월 31일

0 개 추천

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

댓글 수: 2

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 2019년 5월 31일
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.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터 및 File Exchange에서 Errorbars에 대해 자세히 알아보기

질문:

2019년 5월 31일

댓글:

2019년 5월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by