%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% plot_demo.m
%
% purpose: plot figures in matlab
%
% written by tancy 05/08/2017
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%% plot command
% plot(vector_X, vector_Y)

%% simple curve plot

x = -pi:0.01:pi; % define vector x contains a series of values between ?pi and pi
plot(x, sin(x)) % Taking the sine of each of these values (sin(x)) creates the values
                 % sin(x) appears second contains the information for the y-axis of the plot
grid on

%% area plot

x = -pi:0.01:pi; % define vector x contains a series of values between ?pi and pi
area(x, sin(x)) % Taking the sine of each of these values (sin(x)) creates the values
                 % sin(x) appears second contains the information for the y-axis of the plot

%% bar plot

y = [5, 10, 22, 6, 17];
bar(y)

%% demo different style

x = -pi:0.01:pi; 
plot(x, sin(x), 'r+-') % use red and dash curve


%% multiple plot on the same figure

figure() % generate new figure to plot
x = -pi:0.01:pi; 
plot(x, sin(x), 'g-', x, cos(x), 'b-') 

%% add title and legend

figure() % generate new figure to plot
x = -pi:0.01:pi; 
plot(x, sin(x), 'g-', x, cos(x), 'b-') 
title('Sin and Cosine') % add the title
legend('Sine', 'Cosine') % add the name of each curve
%legend('orientation', 'horizontal') % change the orietation of the legend


%% creating a subplot
% subplot(m,n,p) where m and n are the dimensions of the matrix and p is the number of the particular plot within this matrix.
figure()
subplot(1, 3, 1)
p1 = plot(x, sin(x), 'g-'); 
subplot(1, 3, 2)
p2 = plot(x, cos(x), 'b-'); 
subplot(1, 3, 3)
p3 = plot(x, power(x,2), 'r-');


%% more functions in plot
x = 11;
y = 48;
plot(x,y,'r*')
axis([9 12 35 55]) % Change the axes and label them

xlabel('Time')
ylabel('Temperature')
title('Time and Temp')


% clf % clear all figures




