Add legend for a specific plot
Mostrar comentarios más antiguos
I trying to show the legend just for l1, l2 and l3, but when i write legend it show all other legends
how can I show just what i want
here my code
clear;clc
x05 = [0 0.1, 0.2, 0.3, 0.4];
y05 = [0 0.0879, 0.1404, 0.1718, 0.2031];
sdt05 = [0 0.0039, 0.0041, 0.0034, 0.0043];
errorbar(x05,y05,sdt05,'o','MarkerSize',5,...
'MarkerEdgeColor','red','MarkerFaceColor','red', 'Color', 'red')
hold on
f= polyfit(x05,y05,2);
xx = linspace(min(x05), max(x05));
v = polyval(f, xx);
l1= plot(xx,v,'red', ...
'LineWidth',2,...
'MarkerSize',10,...
'MarkerEdgeColor','red',...
'MarkerFaceColor','red', 'DisplayName', 'Rd = 0.5');
hold on
x06= [0 0.1 0.2 0.3 0.4 0.46 0.55];
y06 = [0 0.0849 0.1455 0.1829 0.2202 0.2132 0.1485];
sdt06 = [0 0.0023 0.0035 0.0044 0.0026 0.0123 0.0075];
errorbar(x06,y06,sdt06,'o','MarkerSize',5,...
'MarkerEdgeColor','green','MarkerFaceColor','green', 'Color', 'green')
hold on
f1= polyfit(x06,y06,4);
xx1 = linspace(min(x06), max(x06));
v1 = polyval(f1, xx1);
l2 = plot(xx1,v1,'green', ...
'LineWidth',2,...
'MarkerSize',10,...
'MarkerEdgeColor','green',...
'MarkerFaceColor','green','DisplayName', 'Rd = 0.6');
x064= [0 0.1 0.2 0.3 0.4 0.46 0.55];
y064 = [0 0.0849 0.1465 0.192 0.2101 0.2243 0.1728];
sdt064 = [0 0.0023 0.0019 0.0048 0.0028 0.0037 0.0051];
errorbar(x064,y064,sdt064,'o','MarkerSize',5,...
'MarkerEdgeColor','blue','MarkerFaceColor','blue', 'Color', 'blue')
hold on
f2= polyfit(x064,y064,4);
xx2 = linspace(min(x064), max(x064));
v2 = polyval(f2, xx2);
l3= plot(xx2,v2,'blue', ...
'LineWidth',2,...
'MarkerSize',10,...
'MarkerEdgeColor','blue',...
'MarkerFaceColor','blue','DisplayName', 'Rd = 0.64');
legend()
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Legend en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!