用Matlab画图时,对每一条线设置不了legend
,一番查找之后,在360文档找到解决方法,如下所示:

intact = plot(xin, yin, xi_out, yi_out, 'b');
axis('equal');
hold on;
Rs = Rin:0.005:Rin+(Rout-Rin)*d0;
cd = plot((Rin+(Rout-Rin).*dtheta1).*cos(theta), (Rin+(Rout-Rin).*dtheta1).*sin(theta), 'r', Rs.*cos(beta), Rs.*sin(beta), 'r', Rs.*cos(-beta), Rs.*sin(-beta), 'r');
linear = plot((Rin+(Rout-Rin).*dtheta2).*cos(theta), (Rin+(Rout-Rin).*dtheta2).*sin(theta), 'g');
el = plot((Rin+(Rout-Rin).*dtheta3).*cos(theta), (Rin+(Rout-Rin).*dtheta3).*sin(theta), 'c');
pa = plot((Rin+(Rout-Rin).*dtheta4).*cos(theta), (Rin+(Rout-Rin).*dtheta4).*sin(theta), 'm');
hold off;
legend([intact(1), cd(1), linear, el, pa, l2, l3], 'intact', 'CD', 'Linear', 'EL','PA', 'Location', 'Northwest', '2-order', '3-order');

网友评论