Legend Choose Scatter and not plot
조회 수: 4 (최근 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')
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Legend에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!