Legend Choose Scatter and not plot

2 vues (au cours des 30 derniers jours)
Naty S
Naty S le 27 Sep 2012
hey all My problem is that in my code i first use the scatter command and then i use the plot cmd . when i ask for the matlab to create a legend he goes by the shapes and colors of the scatter instead of the plot, since i got couple of scatters with different shapes this is not good for me . i tried setting the plot to h1=plot(..) but it didn't work. only made the same color too all the legend.. How could i solve this? Thanks Naty
the code i use:
switch j
case 1
scatter(y_stable(i,j),y1(i,j),'*','b');
scatter(y_end(i,j),y_end(i,j),'o','b')
case 2
scatter(y_stable(i,j),y1(i,j),'*','k');
scatter(y_end(i,j),y_end(i,j),'o','k')
case 3
scatter(y_stable(i,j),y1(i,j),'*','r');
scatter(y_end(i,j),y_end(i,j),'o','r')
end
end
end
end
plot(y0,y1,'b',y0,y1(:,2),'k',y0,y1(:,3),'r',y0,y0,'g');
legend(num2str(alpha(1)),num2str(alpha(2)),num2str(alpha(3)),'refrence','location','best')

Réponse acceptée

John Petersen
John Petersen le 3 Déc 2012
legend(num2str(alpha(1)),num2str(alpha(2)),num2str(alpha(3)),'refrence','location','best')
plot(y0,y1,'b',y0,y1(:,2),'k',y0,y1(:,3),'r',y0,y0,'g');

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by