How can I choose to show only part of plot/legend?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Katarina
le 8 Mai 2014
Réponse apportée : Katarina
le 8 Mai 2014
I want to show only one of the "Maxvärde" in the legend.
The code that we used to plot it was:
figure(1);
hold on;
plot(MedelV,'b');
plot(find(Vattenh==(Max)),(Max), 's','MarkerSize',10,'MarkerEdgeColor','k','MarkerFaceColor', 'r');
plot(find(Vattenh==(Min)),(Min), 's','MarkerSize',10,'MarkerEdgeColor','k','MarkerFaceColor', 'y');
plot(Tjugofemperc,'c');
plot(Sjuttiofemperc,'c');
plot(Damnplot,'r');
plot(Sankplot,'r');
plot(x,Vattenh,'k');
lgnd=legend(['Medelvattenstånd ', num2str(Mean, prec),'m'],['Maxvärde ', num2str(Max,prec),'m'],['Maxvärde ', num2str(Max,prec),'m'],['Maxvärde ', num2str(Max,prec),'m'],['Maxvärde ', num2str(Max,prec),'m'],['Minvärde ', num2str(Min,prec),'m'],['25%-percentilen ', num2str(Tjugofem,prec),'m'], ['75%-percentilen ', num2str(Sjuttiofem,prec),'m'],['Dämningsgräns ', num2str(Damn, prec),'m'],['Sänkningsgräns ', num2str(Sank, prec),'m'],'Vattenståndsdata');
rect=[0.63, 0.18, .25, .25];
set(lgnd,'color','none', 'position', rect);
set(gca,'XTick',[0:4:52])
xlabel('Tid i veckor för 2010')
ylabel('Vattenstånd (möh)')
title('Statistiska data för medelvattenståndet i Högsjön under år 2010')
How is this possible??
0 commentaires
Réponse acceptée
Niklas Nylén
le 8 Mai 2014
If you start by only plotting one of the max points by adding a second argument to the find function
plot(find(Vattenh==(Max),1),(Max(1)), 's','MarkerSize',10,'MarkerEdgeColor','k','MarkerFaceColor', 'r');
Make the rest of the plot commands and the legend command with only one instance of the "Maxvärde".
Finally, plot the rest of the max values:
plot(find(Vattenh==(Max)),(Max), 's','MarkerSize',10,'MarkerEdgeColor','k','MarkerFaceColor', 'r');
0 commentaires
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Legend 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!