title: Using ggplot2 how can I plot points with an aes() after plotting lines?
body: <p>I'm using ggplot2 to show lines and points on a plot. What I am trying to do is to have the lines all the same color, and then to show the points colored by an attribute. My code is as follows:</p>
  
  <pre><code># Data frame
  dfDemo &lt;- structure(list(Y = c(0.906231077471568, 0.569073561538186, 
  0.0783433165521566, 0.724580209473378, 0.359136092118470, 0.871301974471722, 
  0.400628333618918, 1.41778205350433, 0.932081770977729, 0.198188442350644
  ), X = c(0.208755495088456, 0.147750173706688, 0.0205864576474412, 
  0.162635017485883, 0.118877260137735, 0.186538613831806, 0.137831912094464, 
  0.293293029083812, 0.219247919537514, 0.0323148791663826), Z = c(11112951L, 
  11713300L, 14331476L, 11539301L, 12233602L, 15764099L, 10191778L, 
  12070774L, 11836422L, 15148685L)), .Names = c("Y", "X", "Z"
  ), row.names = c(NA, 10L), class = "data.frame")
  
  # Variables
  X = array(0.1,100)
  Y = seq(length=100, from=0, by=0.01)
  
  # make data frame
  dfAll &lt;- data.frame()
  
  # make data frames using loop
  for (x in c(1:10)){
  
      # spacemate calc
      Floors = array(x,100)
  
      # include label
      Label = paste(' ', toString(x), sep="") 
      df1 &lt;- data.frame(X = X * x, Y = Y, Label)
  
      # merge df1 to cumulative df, dfAll
      dfAll &lt;- rbind(dfAll, df1)
  
  }
  
  # plot 
  pl &lt;- ggplot(dfAll, aes(x = X, y = Y, group = Label, colour = 'Measures')) + geom_line() 
  
  # add  points to plot
  pl + geom_point(data=dfDemo, aes(x = X, y = Y)) + opts(legend.position = "none")
  </code></pre>
  
  <p>This almost works, but I am unable to color the points by <code>Z</code> when I do this. I can plot the points separately, colored by <code>Z</code> using the following code:</p>
  
  <pre><code>ggplot(dfDemo, aes(x = X, y = Y, colour = Z)) + geom_point()
  </code></pre>
  
  <p>However, if I use the similar code after plotting the lines:</p>
  
  <pre><code>pl + geom_point(data=dfDemo, aes(x = X, y = Y, colour = Z)) + opts(legend.position = "none")
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>Error: Continuous variable () supplied to discrete scale_hue.
  </code></pre>
  
  <p>I don't understand how to add the points to the chart so that I can colour them by a value. I appreciate any suggestion how to solve this.</p>