Settings cb.outline.set_visible()- Falsedeletes the contour, both in the figure and in the saved pdf. I noticed that setting the line width to something small was also reflected in the output file.
import matplotlib.pyplot as plt
import numpy as np
data = np.random.rand(2,2)
im3 = plt.imshow(data)
cb = plt.colorbar(im3)
cb.outline.set_visible(False)
cb.set_ticks([])
plt.savefig("thing.pdf",dpi=1000, bbox_inches='tight')

source
share