Desktop Survival Guide
by Graham Williams

Multiple Line Plots

A line plot displays a line corresponding to one or more variables over some series of data or entities. The matplot function will display multiple lines from data in a matrix. such a plot is useful in observing changes in variables over time or across entities.

In our example we plot just the first 50 entities in the wine dataset, and choose four variables to plot. These kinds of plots can get very crowded if we attempt to plot too much data. A legend is placed in an appropriate location (at the point $x=33, y=4.05$) using the legend function, where we also identify the colours, using Roption[]col, to be the first four in the colour pallete, and the line types, using Roption[]lty, as the firsts four line types.

Image rplot-wine-matplot

cols <- c("Ash", "Phenols", "Proanthocyanins", "Dilution")
matplot(1:50, wine[1:50,cols], type="l", ylab="Observed", xlab="Entity")
legend(30, 4.05, cols, col=1:4, lty=1:4)

Copyright © Togaware Pty Ltd
Support further development through the purchase of the PDF version of the book.
The PDF version is a formatted comprehensive draft book (with over 800 pages).
Brought to you by Togaware. This page generated: Sunday, 22 August 2010