title: Filled areas in gnuplot that disappear when the curve exits the graph area
body: <p>I was about to ask this question here but a minute before doing it I figured how to solve the problem. Since I think other people might have experienced the same issue, I answer my own question.</p>
  
  <p>Imagine that you want to draw a curve and a shade below it, for instance y = x². In gnuplot, something of the sort is realized like this</p>
  
  <pre><code>plot -x**2 with filledcurves x1
  </code></pre>
  
  <p>which yields the following graph:</p>
  
  <p><img src="https://i.stack.imgur.com/n6uzx.png" alt="-x²"></p>
  
  <p>Now imagine that for some reason you want to restrict the range of the y axis so the max. value is -10. Then</p>
  
  <pre><code>set yrange [*:-10]
  plot -x**2 with filledcurves x1
  </code></pre>
  
  <p>yields the following:</p>
  
  <p><img src="https://i.stack.imgur.com/CkQDT.png" alt="-x² with restricted y range"></p>
  
  <p>which looks terrible. Even though you're asking gnuplot to shade the area between the curve and the x axis, the fact that the part of the curve outside the graph is not being rendered is preventing this from happening properly.</p>
  
  <p>How do you fix it? Answer below.</p>