Formatting and Annotating Graphs

 

Formatting graphs

plot(X,Y,'m:s')     % magenta, dotted line, square markers
plot(X,Y,'g--*')    % green, dashed line, star markers
plot(X,Y,'r-')      % red, solid line, no markers
plot(X,Y,'b .')     % blue, no line, dot markers
X = -1:0.1:1;
Y = X.^2;
plot(X, Y, 'r-*')
11-formatted-plot
plot(Y)
% X values take 1:size(Y)
% i.e. size(Y) values starting from 1 with each interval being 1

Annotating Graphs

plot(x,y)
xlabel({'time', '(in seconds)'})
ylabel('amplitude [nm]')
title('My Plot')
legend('y(t)')
x = linspace(-2*pi,2*pi);
y = sin(x);
plot(x,y)
xlabel('-2\pi \leq x \leq 2\pi')
legend('sin(x)_{-2\pi \leq x \leq 2\pi}')
12-annotated-plot