plotting with different colors
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
PChoppala
am 27 Okt. 2015
Beantwortet: Image Analyst
am 27 Okt. 2015
Hi, I have to plot something like
x=0.1:0.1:1;
n=length(x);
f=exp(x);
y=f+0.1*randn(1,n);
figure
plot(x, f, 'b-', x,y,'x', 'color',[.5 .5 .5])
legend('function f','measurement y')
I want f plotted in solid blue and y in crossed gray. It doesn't work. Also the legend does not work properly. Any help is appreciated. (Note that the length of y and f may not be equal at all times.)
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 27 Okt. 2015
Try this:
x=0.1:0.1:1;
n=length(x);
f=exp(x);
y=f+0.1*randn(1,n);
plot(x, f, 'b-', 'LineWidth', 3);
grid on;
hold on;
plot(x, y, 'x', 'color',[.5 .5 .5], 'LineWidth', 2, 'MarkerSize', 9)
legend('function f','measurement y');
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Get rid of tool bar and pulldown menus that are along top of figure.
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Legend finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!