title: Matplotlib: set axis tight only to x or y axis
body: <p>I have a plot look like this:</p>
  
  <p><a href="https://i.stack.imgur.com/5ePuJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5ePuJ.png" alt="enter image description here"></a></p>
  
  <p>Obviously, the left and right side is a waste of space, so I set</p>
  
  <pre><code>plt.axis('tight')
  </code></pre>
  
  <p>But this gives me plot like this:</p>
  
  <p><a href="https://i.stack.imgur.com/lOPO0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lOPO0.png" alt="enter image description here"></a></p>
  
  <p>The xlim looks right now, but the ylim is too tight for the plot.</p>
  
  <p>I'm wondering, if I can only set <code>axis(tight)</code> only to x axis in my case?</p>
  
  <p>So the plot may look something like this:</p>
  
  <p><a href="https://i.stack.imgur.com/RKKfy.png" rel="noreferrer"><img src="https://i.stack.imgur.com/RKKfy.png" alt="enter image description here"></a></p>
  
  <p>It's certainly possible that I can do this manually by</p>
  
  <pre><code>plt.gca().set_xlim(left=-10, right=360)
  </code></pre>
  
  <p>But I'm afraid this is not a very elegant solution.</p>