title: Matplotlib - Set the limits for text wrapping
body: <p>I am trying to generate a plot having four quarters, each having some text saying something about that quarter. However, when I am trying to wrap the text I don't know how to set the limits for text. For example, in the attached figure, I want to limit the text to <i>x=0</i>. However, it is going until the end of x-axis limits. Please find attached the code and corresponding plot the code is generating. </p>
  
  <pre><code>import matplotlib
  %matplotlib inline
  import matplotlib.pyplot as plt
  
  import numpy as np
  from textwrap import wrap
  
  font = {'size': 22}
  matplotlib.rc('font', **font)
  fig = plt.figure(figsize=(8, 8))
  plt.axis([-10, 10, -10, 10])
  
  ax = plt.gca()
  
  ax.spines['left'].set_position('center')
  ax.spines['bottom'].set_position('center')
  
  ax.spines['right'].set_visible(False)
  ax.spines['top'].set_visible(False)
  
  plt.xlabel('Energy ($kWh$)')
  ax.xaxis.set_label_coords(0.85, .48)
  ax.xaxis.set_ticks_position('bottom')
  ax.set_xlim(-10, 10)
  ax.xaxis.set_ticks([])
  
  plt.ylabel('Discomfort ($\%$)', rotation=0)
  ax.yaxis.set_label_coords(0.7, 0.01)
  ax.yaxis.set_ticks_position('left')
  ax.set_ylim(-10, 10)
  ax.yaxis.set_ticks([])
  
  ax.annotate(
      'Reference Point', xy=(0, 0), xycoords='data',
      xytext=(-10, 2), textcoords='data', wrap=True,
      arrowprops=dict(facecolor='black'))
  
  t = "This is a really long string that I'd rather have wrapped so that 
  it doesn't go outside of the figure, but if it's long enough it will go 
  off the top or bottom!"
  
  ax.text(-10, 3.5, t, ha='left', wrap=True, fontsize=20)
  plt.tight_layout()
  plt.savefig('sample.png')
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/NVngO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NVngO.png" alt="Text should be limited to x=0"></a></p>