Effacer les filtres
Effacer les filtres

Error when using legend on contour plot(2014b

3 vues (au cours des 30 derniers jours)
Andreas Burheim Volden
Andreas Burheim Volden le 5 Fév 2015
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 commentaire
Marc Jakobi
Marc Jakobi le 4 Juin 2015
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).

Connectez-vous pour commenter.

Réponses (1)

Marc Jakobi
Marc Jakobi le 4 Juin 2015
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.

Catégories

En savoir plus sur Scatter Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by