import matplotlib.pyplot as plt
import numpy as np

# dummy data
x = y = np.linspace(-np.pi, np.pi, 50)
X, Y = np.meshgrid(x, y)
Z = np.sin(X) * np.cos(2.*Y)

# draw a filled contour plot and add a colorbar with drawedges turned on
contours = plt.contourf(x, y, Z)
cb = plt.colorbar(orientation='horizontal', drawedges=True)

# turn off tick marks so the edges can be seen
for tick in cb.ax.get_xticklines() + cb.ax.get_yticklines():
    tick.set_visible(False)

# save as a PDF and a PNG
plt.savefig('test.pdf')
plt.savefig('test.png')

