title: R, ggplot when changing colors/line style: Error in grid.Call.graphics
body: <p>I have some R code to draw a plot. It looks like the image below: </p>
  
  <p><img src="https://i.stack.imgur.com/eEszZ.png" alt="enter image description here"></p>
  
  <p>Now I want to be able to set the line color and style (need it in grey values), add the two straight lines to the legend and remove the title of the legend. </p>
  
  <p>This code works (I put fake data): </p>
  
  <pre><code>library(ggplot2)
  
  load ("vns.data")
  load ("rw.data")
  load("gibbs.data")
  </code></pre>
  
  <p>if you don't load data, do this: </p>
  
  <pre><code>vtm1&lt;- c(1,3,4)
  vmean&lt;-c(3.9,3.8,3)
  vmax&lt;-c(4.1,4.2,4)
  vmin&lt;-c(3,2.5,2)
  rtm1&lt;- c(1,2,4,5)
  rmean&lt;-c(3.9,3.85,3.7,3.1)
  rmax&lt;-c(4.1,4.2,4,3.9)
  rmin&lt;-c(3,2.5,2,1.9)
  gtm1&lt;- c(2,4,5)
  gmean&lt;-c(4.1,3.9,3)
  gmax&lt;-c(4.1,4,3.9)
  gmin&lt;-c(3,2.5,1.5)
  vns &lt;- data.frame(vtm1, vmean, vmax, vmin)
  gibbs &lt;- data.frame(gtm1, gmean, gmax, gmin)
  rw &lt;- data.frame(rtm1, rmean, rmax, rmin)
  </code></pre>
  
  <p>Then continue</p>
  
  <pre><code>names(vns) &lt;- c("tm1", "mean", "max", "min")
  names(gibbs) &lt;- c("tm1", "mean", "max", "min")
  names(rw) &lt;- c("tm1", "mean", "max", "min")
  vns$what &lt;- "VNS"
  gibbs$what &lt;- "GS"
  rw$what &lt;- "RW"
  
  
  DF &lt;- do.call(rbind, list(vns, gibbs, rw))
  
  
  
  
  plt &lt;- ggplot(DF, aes(x= tm1, ymin= min, ymax= max, y=mean)) +
  xlab("Number of TM lookups") + 
  ylab("Cross-entropy")+
  geom_hline(yintercept=3.2240952381, linetype = "dotted", color="#A8A8A8")+ 
  geom_hline(yintercept=3.44366666666667, linetype = "dotted") + 
  geom_ribbon(aes(fill=what), alpha=0.3) +  
  geom_line(aes(linetype = what))+
  theme_bw( )+
  
  
   scale_colour_manual(name="what", values=c("vns"="#A8A8A8", "gibbs"="#E8E8E8", "rw"="#C8C8C8")) +  
      scale_fill_manual(name="what", values=c("vns"="#A8A8A8", "gibbs"="#E8E8E8", "rw"="#C8C8C8"))+
      scale_linetype_manual(name="what", values=c("vns"="solid", "gibbs"="dotdash", "rw"="dashed")) 
      print(plt)
  </code></pre>
  
  <p>This code works, when these lines are removed:</p>
  
  <pre><code>scale_colour_manual(name="what", values=c("vns"="#A8A8A8", "gibbs"="#E8E8E8", "rw"="#C8C8C8")) +  
  scale_fill_manual(name="what", values=c("vns"="#A8A8A8", "gibbs"="#E8E8E8", "rw"="#C8C8C8"))+
  scale_linetype_manual(name="what", values=c("vns"="solid", "gibbs"="dotdash", "rw"="dashed")) 
  </code></pre>
  
  <p>I get the following error with my real data. With the toy data, it works fine. </p>
  
  <pre><code>Error in grid.Call.graphics(L_lines, x$x, x$y, index, x$arrow) : 
    invalid line type
  </code></pre>
  
  <p>With the toy data, it works fine. Yet, the horizontal lines need to be added to the legend, and the legend name removed. Therefore, I have made my real data available here: <a href="https://dl.dropboxusercontent.com/u/13564139/vns.saved" rel="nofollow noreferrer">https://dl.dropboxusercontent.com/u/13564139/vns.saved</a> and <a href="https://dl.dropboxusercontent.com/u/13564139/rw.saved" rel="nofollow noreferrer">https://dl.dropboxusercontent.com/u/13564139/rw.saved</a> and <a href="https://dl.dropboxusercontent.com/u/13564139/gibbs.saved" rel="nofollow noreferrer">https://dl.dropboxusercontent.com/u/13564139/gibbs.saved</a></p>
  
  <p>Any idea what can cause this error, and why only with the real data, not the toy data? I have already rebooted as suggested in some other posts here.</p>
  
  <p><img src="https://i.stack.imgur.com/z4tkS.png" alt="enter image description here"></p>