title: plot multiple line segments on one graph using R
body: <p>How can I duplicate this style of graph, with multiple plots on one graph, and, preferably, legends attached as below.</p>
  
  <p>I have tried the concept of "facet" but ggplot2 and trellis:xyplot both think of facets as separate panels rather than overlaid plots.</p>
  
  <p>I can do it using plain Jane plot() and line().. but was using ggplot2 and woudl like to get multiple lines on one plot in that package.</p>
  
  <p>Here is some example data in long form (captured from the plot using a nifty app called "Graphclick") </p>
  
  <pre><code>comp &lt;- read.table(pipe("pbpaste"), header=T, sep=',')
  
  company, year, sales
  Apple,1975.003,17298.457
  Apple,1977.302,16784.502
  Apple,1978.314,17298.457
  Apple,1980.246,20730.098
  Apple,1981.533,27608.426
  Apple,1984.293,40862.852
  Apple,1986.408,50468.617
  Apple,1987.328,48236.188
  Apple,1988.892,35676.547
  Apple,1989.904,34616.582
  Apple,1991.192,44732.742
  Apple,1992.387,44732.742
  Apple,1993.399,39055.324
  Apple,1995.791,37894.922
  Apple,1996.895,39648.746
  Apple,1998.274,52804.367
  Apple,1999.378,61399.512
  Apple,2001.770,2.350e5
  Apple,2005.265,7.735e5
  Toshiba,1999.378,86856.6
  Toshiba,2001.862,1.192e5
  Toshiba,2004.069,1.495e5
  Toshiba,2004.069,1.495e5
  IBM,1975.003,22019.092
  IBM,1975.830,27195.193
  IBM,1976.934,30682.320
  IBM,1978.130,31148.527
  IBM,1980.430,35676.547
  IBM,1981.625,35676.547
  IBM,1983.005,39648.746
  IBM,1985.305,40862.852
  IBM,1986.408,46102.508
  IBM,1987.512,64241.156
  IBM,1989.996,75832.898
  IBM,1991.100,84276.039
  IBM,1992.295,85556.641
  IBM,1993.307,79342.539
  IBM,1994.779,79342.539
  IBM,1995.791,84276.039
  IBM,1996.895,95082.484
  IBM,1996.895,95082.484
  Commodore,1975.003,33588.051
  Commodore,1975.830,34616.582
  Commodore,1977.118,25219.982
  Commodore,1978.130,23388.229
  Commodore,1979.326,25992.234
  Commodore,1980.521,21689.514
  Commodore,1981.717,25219.982
  Commodore,1984.201,6999.029
  Commodore,1985.213,1670.460
  Commodore,1986.408,1458.447
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/M6Zab.png" rel="nofollow noreferrer" title="Computing over time"><img src="https://i.stack.imgur.com/M6Zab.png" alt="computing over time" title="Computing over time"></a><br>
  <sub>(source: <a href="http://www.asymco.com/wp-content/uploads/2012/01/Screen-Shot-2012-01-18-at-1-18-4.31.31-PM.png" rel="nofollow noreferrer">asymco.com</a>)</sub>  </p>