【发布时间】:2014-09-19 11:49:55
【问题描述】:
我想画四个圆,两种颜色。我正在使用圆形功能来绘制一个圆圈。我遇到了legend() 的问题。它将两个数据用相同的颜色着色。
function main
clear all
clc
circle([ 10, 0], 3, 'b')
circle([-10, 0], 3, 'b')
circle([ 10, 10], 3, 'r')
circle([-10, 10], 3, 'r')
% Nested function to draw a circle
function circle(center,radius, color)
axis([-20, 20, -20 20])
hold on;
angle = 0:0.1:2*pi;
grid on
x = center(1) + radius*cos(angle);
y = center(2) + radius*sin(angle);
plot(x,y, color, 'LineWidth', 2);
xlabel('x-axis');
ylabel('y-axis');
title('Est vs Tr')
legend('true','estimated');
end
end
下图显示了问题。两种颜色都是蓝色,其中一个是红色。
有什么建议吗?
【问题讨论】: