Legend Choose Scatter and not plot

2 次查看(过去 30 天)
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')

采纳的回答

John Petersen
John Petersen 2012-12-3
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');

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Legend 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by