Saint Louis University |
Computer Science 145
|
Dept. of Math & Computer Science |
Topic: Plotting Data
Related Reading: Ch. 11 as well as coverage from
lecture.
Due:
Wednesday, 4 February 2009, 11:59pm
Please make sure you adhere to the policies on academic integrity.
For each of the following problems, your goal is to create a script that precisely replicates the figure that we demonstrate. Please make sure to pay attention to issues like axis bounds, labels, titles, legends, and other such aesthetics. You should be submitting four separate fies: arch.m, sunflower.m, population.m, and stock.m. Submit those m-files in accordance with cs.slu.edu/~goldwasser/145/submit.
Create a script sunflower.m that produces such a figure (note well that displayed axes are intentionally omitted from the figure).
For your own amusement you might see what kind of patterns you get by slightly modifying the value of , but submit the version with the prescribed value.
Population growth can often be modeled with the following function:
For this problem, we want you to graph the population estimate when compared to the actual data for the U.S. population for the period from 1650 up to 2000. We are providing a text file with the actual raw data (statistics taken from wikipedia). Our file has a simple format, starting as
1650 50400 1670 111900 1690 210400 1700 250900You may download the file population.txt to save in your working directory. It can be loaded from within a MATLAB script with a command such as
pop = load('population.txt');in which case the variable pop will be set to an array with n rows and 2 columns.
Write a script population.m that reproduces the following
figure, with the blue dots being the actual data read from the file
and the red line being the estimating function (you can plot the blue
dots in MATLAB by using a line specification of 'b.').
Many financial web sites will display charts similar to the one shown
below showing the price of the Dow Jones Industrial Average as well as
the overall market volume for each day of the most recent year (figure
courtesy of
Yahoo
Finance).
Yahoo also shares its raw data, not
just for the year but for its full history. For this assignment, we
have downloaded the raw data for the Dow Jones going back to 1928.
Our goal is to use MATLAB to reproduce a similar view of the most
recent year.
We are providing the raw data in a text file (download here), wih one row for each day
of market activity. It is arranged in columns that designate
Year | Month | Day | Daily Opening Price | Daily High Price | Daily Low Price | Daily Closing Price | Daily Volume |
---|---|---|---|---|---|---|---|
1928 | 10 | 01 | 239.43 | 242.46 | 238.24 | 240.01 | 3500000 |
1928 | 10 | 02 | 240.01 | 241.54 | 235.42 | 238.14 | 3850000 |
... | |||||||
2009 | 01 | 29 | 8373.06 | 8373.06 | 8092.14 | 8149.01 | 5067060000 |
2009 | 01 | 30 | 8149.01 | 8243.95 | 7924.88 | 8000.86 | 5350580000 |
Your goal:
You should create a script stocks.m that generates a figure
mimicking the one shown above, as best possible (we do not expect
you to be able to match all of the aestetics for this one). We will help you
out with the following advice.
For this week, feel free to use advanced knowledge about the data set to mimic the figure. In particular, the entry for 2008-01-30 is on row 19919 of that file.
The top portion of the figure is a line graph based upon plotting the daily closing prices.
set(gca, 'YTick', 1000 .* [1:20]); set(gca, 'YTickLabel', 1000 .* [1:20]);
set(gca, 'YaxisLocation', 'right');
The bottom figure is a bar graph based upon the daily volume.
Extra credit about stock market graph with high/low error bars coming soon. Goal will be to produce a graph somewhat like the one below, based on use of the errorbar command and the daily open/high/low/close values.
(figure
courtesy of marketwatch.com)