title: Format y axis as percent
body: <p>I have an existing plot that was created with pandas like this:</p>
  
  <pre><code>df['myvar'].plot(kind='bar')
  </code></pre>
  
  <p>The y axis is format as float and I want to change the y axis to percentages.  All of the solutions I found use ax.xyz syntax and <strong>I can only place code below the line above that creates the plot</strong> (I cannot add ax=ax to the line above.) </p>
  
  <p><strong>How can I format the y axis as percentages without changing the line above?</strong></p>
  
  <p>Here is the solution I found <strong>but requires that I redefine the plot</strong>:</p>
  
  <pre><code>import matplotlib.pyplot as plt
  import numpy as np
  import matplotlib.ticker as mtick
  
  data = [8,12,15,17,18,18.5]
  perc = np.linspace(0,100,len(data))
  
  fig = plt.figure(1, (7,4))
  ax = fig.add_subplot(1,1,1)
  
  ax.plot(perc, data)
  
  fmt = '%.0f%%' # Format you want the ticks, e.g. '40%'
  xticks = mtick.FormatStrFormatter(fmt)
  ax.xaxis.set_major_formatter(xticks)
  
  plt.show()
  </code></pre>
  
  <p>Link to the above solution: <a href="https://stackoverflow.com/questions/26294360/pyplot-using-percentage-on-x-axis">Pyplot: using percentage on x axis</a></p>