How do I modify the legend in a Matlab plot? -
i draw 4 circles of 2 colors. i'm using circle function draw circle. i'm facing problem legend()
. colors 2 data same color.
function main clear clc circle([ 10, 0], 3, 'b') circle([-10, 0], 3, 'b') circle([ 10, 10], 3, 'r') circle([-10, 10], 3, 'r') % nested function draw 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
the following picture shows problem. both colored blue instead 1 of them red.
any suggestions?
the thing draw 4 things , have 2 entries in legend. such pick color of first 4 things color legend.
not in opportunity try myself now, guess easiest 'solution' draw third circle first , second one.
circle([ 10, 0], 3, 'b') circle([ 10, 10], 3, 'r') circle([-10, 0], 3, 'b') circle([-10, 10], 3, 'r')
Comments
Post a Comment