How can I choose to show only part of plot/legend?

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??

 채택된 답변

Niklas Nylén
Niklas Nylén 2014년 5월 8일
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');

추가 답변 (1개)

Katarina
Katarina 2014년 5월 8일

0 개 추천

Thank you! It worked perfectly!

카테고리

태그

질문:

2014년 5월 8일

답변:

2014년 5월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by