title: Python 3 Adding a Colorbar with Matplotlib
body: <p>I've done a fair amount of research on adding a colorbar to a plot but I'm still really confused about how to add one. The examples I've seen use different ways of doing so, which just confuses me because I don't get what the "right" way is.</p>
  
  <p>I've seen there is a colorbar method and a colorbar() function, so what should one use to simply add a colorbar?</p>
  
  <p>Some examples do this: </p>
  
  <pre><code>fig,ax = plt.subplots()
  s = ax.scatter(x,y,cmap = coolwarm)
  matplotlib.colorbar.ColorbarBase(ax=ax, cmap=coolwarm, values=sorted(v),
                               orientation="horizontal")
  </code></pre>
  
  <p>While some others simply call the function:</p>
  
  <pre><code>fig = plt.figure()
  ax = fig.add_subplot(1, 1, 1)
  image = np.random.poisson(10., (100, 80))
  i = ax.imshow(image, interpolation='nearest')
  fig.colorbar(i)
  </code></pre>
  
  <p>I'm probably missing something here, but I just don't see how these both create a colorbar (I just copied the code for the colorbar and excluded that of the data).</p>
  
  <p>My question is simply: what is the simplest way to add a colorbar to a plot?
  Thanks!</p>