[Return to syllabus page]

Statistics 200: Lab 7

Today's tasks:
Low-level graphics. Construction of customized plots.

Much of what you have to do this week depends on the par() function. The Splus help page for par() is rather long; it is hard to find information about a specific argument. I have created an abbreviated help page for par. My page includes a link to an html version of the Splus help page, which you can search using Netscape.

Problem 1

Try:
par("din"); par("fin");par("pin");par("usr")
plot(runif(100),runif(100))
par("din"); par("fin");par("pin");par("usr")
lines(c(0,1),c(0,1))
lines(c(0.5,1),c(0,2))
par(xpd=T)
lines(c(0.5,1),c(0,2))
Explain to BM or DP what is going on. What do the various par(...) settings control? Try resizing the graphics window (using the mouse), then repeat the experiment. What does "inch" mean?


Often you will find yourself wanting to fiddle with some par setting, to get some fine graphics effect. A good habit to get into, especially inside functions, is
oldpar <- par() # save all the old settings
# now make all your changes to par
# ...
# finished with the graphics
par(oldpar)  # restore the old settings as you leave
You could also save just those par values that will be affected, and then restore those values as you leave--see the examples at the end of the help page for par.

Problem 2

Draw the biggest circle on the graphics device that you can. Draw the largest rectangle that you can. Draw two diagonals (a `big X') of the largest rectangle. (The big X should have endpoints at the corners of the graphics device surface.) No cheating: don't use locator to find the corner points. For a truly virtuoso effort, try drawing the `big X' without changing the margin sizes. Hint: You can change the usr coordinates if you want to. (We found usr, plt, and xpd useful parameters.) For big circles, you could try symbols(), but the various arguments are tricky. We will settle for a square if you have too much troble with circles. To orient youself, you might take a peek at this rather garish picture showing the meanings of some important graphics parameters.

Problem 3

(Optional. Skip if you are short of time. Actually, you should skip this problem if you are averse to pain and suffering. Split.screen() gets hard to control after a while. Maybe you should could use mfrow() instead.) Write a function to draw the big X, as in the previous problem. Split the device into a 2 by 3 array of figures, using split.screen(). Draw a big X in the screens in the top left corner and the bottom right corner, with the screen number (1 or 6) written in the middle in a large letter.


The next three problems refer to an old maps data set (taken from a book by Andrews and Herzberg), which we will also be using next week. You can find the data in the maps section of the library. You could also get it from the WWW, if you feel the need for more read.table() practice: From the StatLib---Andrews & Herzberg Archive , get the old maps data set (Table 10.1). Read it into a data frame. Warning: How can there be 78 rows if there are only 39 points? You will have a little work to do to get the data into the format you need.

Description of the data (taken from the Andrews and Herzberg book, page 63):

Great Lakes area. The data are taken from the eleven maps listed in Table 10.2. These maps are believed to be representative of the period of time commencing with the widespread knowledge that five major lakes existed in the interior of North America, and ending when relatively large scale hydrographic surveys of the lakes' shorelines were being done.

The data shown in Table 10.1 consist of the latitude, [phi], and longitude, [lambda], co-ordinates, as determined for each map, for each of 39 points easily identifiable on the eleven maps. These data were obtained by placing a grid over the old maps and doing a linear interpolation. Interpolation accuracy is felt to be good except for the indicated numbers. Also included are the current co-ordinates for the 39 points.

It is conjectured that there are five key ways a map might be systematically in error. These are: a constant error in latitude, a constant error in longitude, a proportional error in latitude, a proportional error in longitude, and error resulting in a non-zero angle between true North and the map's North. In addition, groups of locations, for example, one whole lake, may be off.

The primary task is to develop a methodology for parameterizing each map with respect to these characteristics and with respect to any other characteristics that seem to be important

Note: A minus sign indicates that the interpolation accuracy is not good.

Problem 4

Pick any of the old maps (for example, Coronelli 1688). Draw a plot of the actual points, as a map. Be sure that you have 'west' pointing to the left, and that the horizontal axis is labelled with the degrees west. If you are ambitious, try to superimpose a map of the US (using the usa() function), so that you can see where the landmarks are.

Problem 5

Draw a plot showing both actual locations and the locations for one of the oldmaps, with arrows joining each actual point to its location on the old map. Warning: look at the data for funny values.

Problem 6

(For the real enthusiasts) Pick an old map. Fit a linear model to both oldmap$lat and oldmap$long, using actual latitude and longitude as predictors. Draw a picture showing the actual locations, with arrows attached indicating the residuals from the linear fits.