필터 지우기
필터 지우기

Error when using legend on contour plot(2014b

조회 수: 3 (최근 30일)
Andreas Burheim Volden
Andreas Burheim Volden 2015년 2월 5일
답변: Marc Jakobi 2015년 6월 4일
When using a script that performs a contour plot I get the following message when trying to add a legend:
Warning: Error updating Legend. Following is the chain of causes of the error:
Index exceeds matrix dimensions.
The script is working fine when using 2014a, so there have been some changes made from 2014a to 2014b that I don't seem to grasp.
Anyone who could fill me in on this particular problem? Cheers!
  댓글 수: 1
Marc Jakobi
Marc Jakobi 2015년 6월 4일
Have you found a solution to this problem yet? I am having the same problem with scatter. My code:
hx = figure;
subplot(211)
h(1) = plot((1:1:8),nanmean(LI_brutto2),'k','LineWidth',2); hold on
for i = 1:size(LI_brutto,1)
h(i+1) = scatter((1:1:8),LI_brutto2(i,:),'r','filled'); hold on %#ok<*SAGROW>
end
h(i+2) = line([4.5 4.5],[0 3500],'Color','k');
L = {'Mittelwert','Spez. Speicherpreis brutto'};
order = [2 1];
legend(h(order),L(order))
There is no problem when trying to access h(1). But as soon as I try to access h(2+) using legend() I get the error message. If I put h(2) or h([2 3 4]) in the workspace, I get a 1xN graphics array (Scatter Scatter Scatter).

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

답변 (1개)

Marc Jakobi
Marc Jakobi 2015년 6월 4일
Okay, I found the reason for my problem. Maybe it might help you, too. The matrix I was scattering contained NaNs. I removed all the NaNs and now the legend works.

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by