title: How set the limits of the plotting area of a multiple line graph (ggplot) when x values are of type factor?
body: <p>My graph looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/5OWY5.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5OWY5.jpg" alt="graph"></a></p>
  
  <p>The code I use is this</p>
  
  <pre><code>graph_substrat &lt;- ggplot(substrat_long, aes(x=substrat,y=value, 
  + group=variable, linetype=variable)) + geom_line() + ylab("Suitability Index") 
  + xlab("Substrat") + background_grid(major = "xy", minor = "none")
  
  graph_substrat &lt;- graph_substrat + theme(legend.position="none") 
  </code></pre>
  
  <p>I only want to plot the line between <em>Cobble</em> and <em>Sand</em>, and delete the free space in the beginning and end of the graph, so that the lines start at the Y-axis (or at least very close to it, and ends with the the last tick on the X-axis).</p>
  
  <p>I tried it with <code>limits</code>, <code>expand</code> and <code>coord_cartesian</code>, but it did not work.</p>
  
  <p>Note that X is of type <code>factor</code> and not <code>numeric</code>.</p>