How can adjust the heatmap in matplotlib?

I have two files with one columns of numbers each one, and I've created a heatmap as you can see in the next figure:

enter image description here

I'm trying to adjust the heatmap that i've created for have a figure like this:

enter image description here

I mean, I want adjust the number of the colorbar between 0 and 1 as the figure above. And, I don't want to have space white on the bord of the axes. So, What is I need to change o add to the script, for doing this?

I'm using the next script. Thanks a lot for your support.

from matplotlib import ticker
import numpy as np
import numpy.random
import matplotlib.pyplot as plt

# Create data
x = open("file1.txt").read().splitlines() 
y = open("file2.txt").read().splitlines()

f = np.random.normal(x).astype(np.float)
g = np.random.normal(y).astype(np.float)

# Create heatmap
heatmap, xedges, yedges = np.histogram2d(f, g, bins=(50,50))
extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]
#heatmap = plt.pcolor(np.histogram2d(f, g, bins=(100,100), cmap=cmap,norm=norm)

# Plot heatmap
plt.clf()
plt.title('heatmap example')
plt.ylabel('y') 
plt.xlabel('x')
plt.imshow(heatmap, cmap='Blues', extent=extent)
cb = plt.colorbar()
tick_locator = ticker.MaxNLocator(nbins=10)
cb.locator = tick_locator
cb.update_ticks()
plt.show()