title: Plotting vertical/horizontal lines that intersect line graph on ggplot
body: <p>The following code produces the following plot:</p>
  
  <pre><code>time_step &lt;- c(1:5, 1:5)
  
  perceived_signal_slow &lt;- c(1:5, cumsum(1:5))
  
  signal_name &lt;- c("perceived","perceived","perceived","perceived","perceived","accumulated","accumulated","accumulated","accumulated","accumulated")
  
  df &lt;- cbind(perceived_signal_slow, signal_name, time_step)
  
  df &lt;- as.data.frame(df)
  
  df$time_step &lt;- as.numeric(as.character(df$time_step))
  df$perceived_signal_slow &lt;- as.numeric(as.character(df$perceived_signal_slow))
  
  ggplot(df, aes(x = time_step, y = signal, colour = signal_name)) +
    geom_line() +
    geom_vline(xintercept = 4, colour = "black", size = 1, alpha = .4) +
    geom_hline(yintercept = 10, colour = "black", size = 1, alpha = .4) +
    geom_hline(yintercept = 4, colour = "black", size = 1, alpha = .4)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/YXF0c.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YXF0c.png" alt="plot"></a>
  However <strong>I want to limit the vertical and horizontal lines</strong> so that they don't travel any further once they hit the accumulated and perceived lines of my graph. Does anybody know how I could alter my code to do this?</p>
  
  <p>Thanks in advance for the help!</p>