Session Ready
Exercise

Plotting areas

At school we were taught to make the most of a piece of graph paper by scaling our data to fit the page. R will usually follow this advice by making a plot fill the graphics window.

With spatial data, this can cause misleading distortion that changes the distance and direction between pairs of points. The data in the previous exercise was created in a tall, skinny rectangle, and it should always be shown as a tall, skinny rectangle. If R stretches this to fill a wide graphics window then it is misrepresenting the relationship between events in the up-down and left-right directions.

So spatial plots should have scales so that one unit in the X axis is the same size as one unit on the Y axis. Circles will appear as circles and not ellipses, and squares will appear square.

The ratio of the Y axis scale to the X axis scale is called the aspect ratio of the plot. Spatial data should always be presented with an aspect ratio of 1:1.

Instructions
100 XP

The boundaries of the rectangle have been pre-defined as xmin, xmax, ymin, and ymax. The x and y coordinates of the points have been pre-defined as x and y, respectively.

  • Edit the body of the mapxy() function to plot the points using the x and y vectors.
  • Call mapxy() with the correct aspect ratio a to get the map looking right. You should get points in a rectangle twice as high as it is wide.