フィルターのクリア

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 Center および File ExchangeScatter Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by