% Program: stocks.m
% Author:  Michael Goldwasser
% This is a solution for CSCI-145, asgn03

clf;                                            % clear current figure
raw = load('djia.txt');
window = raw(19919:end,:);                      
subplot(2,1,1);
semilogy(window(:, 7), 'LineWidth', 2);
title('Dow Jones Industrial Average');

% set vertical axis bounds rounding down/up to nearest thousand
ymin = floor(min(window(:,7)/1000)) * 1000;     
ymax = ceil(max(window(:,7)/1000)) * 1000;
axis([1 length(window) ymin ymax]);
set(gca, 'YTick', 1000 .* [1:20]);
set(gca, 'YTickLabel', 1000 .* [1:20]);
set(gca, 'YAxisLocation', 'right');

% use knowledge of when months begin.  Could determine this with
% control structures to be more robust
set(gca, 'XTick', [3 23 43 65 86 107 129 150 171 194 213 235]);
set(gca, 'XTickLabel', {'2008', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', '2009'});
grid on;
hold on;

% plot the volume
subplot(2,1,2);
bar(window(:,8),0.005);
oldaxis = axis();                                         % returns the default axis bounds
axis([0 length(window(:,8)) oldaxis(3) oldaxis(4)]);      % change the x bounds to match first plot
set(gca, 'YAxisLocation', 'right');
grid on;

hold off;
