 %% Example 1
figure(1)
x = -10:1:10;
y = 4*x +30;

plot(x,y)



%% Example 2
figure(2)
x = -10:1:10;
y = 4*x +30;
y2 = x-x;

plot(x,y)
hold on
plot(x,y2)
hold off


%% Example 3
figure(3)
x = -10:1:10;
y = 4*x +30;
sig = 0.1*y; % noise is 10% of y

errorbar(x,y,sig)


%% Example 4
figure(4)
x = -10:1:10;
x2 = 10.^x;
y = x.^3;

semilogx(x2,y);


%% Example 5
figure(5)
x = -10:1:10;
y = abs(x); % the absolute value of x
y2 = 10.^y;

semilogy(x,y2);


%% Example 6
figure(6)
x = -10:1:10;
x2 = 10.^x;
y = sin(x)*100;
y2 = 10.^y;

loglog(x2,y2);


%% Example 7
figure(7)
x = -10:1:10;
y2 = x.^2;

plot(x,y2,'r*-')


%% Example 8
figure(8)
x = -10:1:10;
y = 4*x +30;
y2 = x.^2;

plot(x,y,'c:')
hold on
plot(x,y2,'y--')
hold off


%% Example 9
figure(9)
x = 0:1:24;
y = sin((x+18)/4)*7+20;

plot(x,y,'r','linewidth',5)


%% Example 10
figure(10)
x = 0:1:24;
y = sin((x+18)/4)*7+20;

plot(x,y,'r','linewidth',5)
xlabel('Time (h)')
ylabel('temperature (C)')
title('Temperature over a day');


%% Example 11
figure(11)
x = 0:1:24;
y = sin((x+18)/4)*7+20;
y2 = sin((x+20)/4)*7;
lw = 5;

plot(x,y,'r','linewidth',lw)
hold on
plot(x,y2,'b','linewidth',lw);
hold off
xlabel('Time (h)')
ylabel('temperature (C)')
title('Temperature over a day');
legend('July','January');


%% Example 12
figure(12)
x = 0:1:24;
y = sin((x+18)/4)*7+20;
y2 = sin((x+20)/4)*7;
lw = 5;

plot(x,y,'r','linewidth',lw)
hold on
plot(x,y2,'b','linewidth',lw);
hold off
xlabel('Time (h)')
ylabel('temperature (C)')
title('Temperature over a day');
legend('July','January','location','best');
% legend('July','January','location','northwest');


%% Example 13
figure(13)
x = 0:1:24;
y = sin((x+18)/4)*7+20;
y2 = sin((x+20)/4)*7;
lw = 5;

plot(x,y,'r','linewidth',lw)
hold on
plot(x,y2,'b','linewidth',lw);
hold off
xlabel('Time (h)')
ylabel('temperature (C)')
title('Temperature over a day');
legend('July','January','location','best');
set(gca,'fontsize',15);



%% Example 14
figure(14)
x = 0:1:24;
y = sin((x+18)/4)*7+20;
y2 = sin((x+20)/4)*7;
lw = 5;
fontsize1 = 15;
fontsize2 = 20;

plot(x,y,'r','linewidth',lw)
hold on
plot(x,y2,'b','linewidth',lw);
hold off
myHandle1 = xlabel('Time (h)');
myHandle2 = ylabel('temperature (C)');
myHandle3 = title('Temperature over a day');
myHandle4 = legend('July','January','location','best');
set(gca,'fontsize',fontsize1);
set(myHandle1,'fontsize',fontsize2);
set(myHandle2,'fontsize',fontsize2);
set(myHandle3,'fontsize',fontsize2);
set(myHandle4,'fontsize',fontsize2);



%% Example 15
figure(15)
x = 0:1:24;
y = sin((x+18)/4)*7+20;
y2 = sin((x+20)/4)*7;
lw = 5;
fontsize1 = 15;
fontsize2 = 20;

plot(x,y,'r','linewidth',lw)
hold on
plot(x,y2,'b','linewidth',lw);
hold off
set(gca,'Xlim',[10 15]);
set(gca,'Ylim',[0 30]);
%note: an easier way to set the limits is using the axis(xmin xmax ymin ymax) option. In this case it would like like this:
%axis([10 15 0 30]);
%but it does require you to set all 4 values (both xlim and ylim)

myHandle1 = xlabel('Time (h)');
myHandle2 = ylabel('temperature (C)');
myHandle3 = title('Temperature over a day');
myHandle4 = legend('July','January','location','best');
set(gca,'fontsize',fontsize1);
set(myHandle1,'fontsize',fontsize2);
set(myHandle2,'fontsize',fontsize2);
set(myHandle3,'fontsize',fontsize2);
set(myHandle4,'fontsize',fontsize2);



%% Example 16
figure(16)
x = 0:1:24;
y = sin(x);
y2 = cos(x);
y3 = tan(x);
y4 = atan(x);
lw = 5;
fontsize1 = 15;
fontsize2 = 20;

subplot(2,2,1) %specifies which sub-window to plot in. 2x2 is always constant (it's the size of the array). Only the last number will change
plot(x,y,'r','linewidth',lw)
myHandle1 = xlabel('x');
myHandle2 = ylabel('sin(x)');
set(gca,'fontsize',fontsize1);
set(myHandle1,'fontsize',fontsize2);
set(myHandle2,'fontsize',fontsize2);


subplot(2,2,2)
plot(x,y2,'b','linewidth',lw)
myHandle1 = xlabel('x');% you might wish to use a new name for the handle, so that you don't overwrite the ones used for subplot 1.
myHandle2 = ylabel('cos(x)');
set(gca,'fontsize',fontsize1);
set(myHandle1,'fontsize',fontsize2);
set(myHandle2,'fontsize',fontsize2);

subplot(2,2,3)
plot(x,y3,'g','linewidth',lw)
myHandle1 = xlabel('x');
myHandle2 = ylabel('tan(x)');
set(gca,'fontsize',fontsize1);
set(myHandle1,'fontsize',fontsize2);
set(myHandle2,'fontsize',fontsize2);

subplot(2,2,4)
plot(x,y4,'k','linewidth',lw)
myHandle1 = xlabel('x');
myHandle2 = ylabel('atan(x)');
set(gca,'fontsize',fontsize1);
set(myHandle1,'fontsize',fontsize2);
set(myHandle2,'fontsize',fontsize2);

%% Example 17
figure(17)
ORANGE = [255 	165 	0]/255;
lw = 5;
fontsize1 = 15;
fontsize2 = 20;

x = 0:1:24;
y = sqrt(x);

plot(x,y,'linewidth',lw,'color',ORANGE)
myHandle1 = xlabel('x');
myHandle2 = ylabel('sqrt(x)');
myHandle3 = title('An orange color');
myHandle4 = legend('x^½','location','best');
set(gca,'fontsize',fontsize1);
set(myHandle1,'fontsize',fontsize2);
set(myHandle2,'fontsize',fontsize2);
set(myHandle3,'fontsize',fontsize2);
set(myHandle4,'fontsize',fontsize2);



%% Example 18
figure(18)
lw = 5;
a = line([10 15],[3 8]);
set(a,'linewidth',lw);

b = rectangle('Position',[10, 10, 5,3]); %change the curvature property to make a circle
set(b,'linewidth',lw);

hold on
c = fill([1 2 7 5 8 4 2 1],[9 3 14 7 2 1 5 9],'g');
hold off
set(c,'linewidth',lw);
d = text(10,2,'Some text');
set(d,'fontsize',15);
set(gca,'Xlim',[0 17]);
set(gca,'Ylim', [0 15])

