You can do it, but there's no particular method devoted to just that. (Perhaps there should be.) Instead, you can manually modify the alpha
value of cbar.solids
.
For example, let's demonstrate the general problem:
import numpy as np
import matplotlib.pyplot as plt
data = np.random.random((10,10))
fig, ax = plt.subplots()
im = ax.imshow(data, cmap='gist_earth', alpha=0.5)
cbar = fig.colorbar(im)
plt.show()

And then if we change the transparency of cbar.solids
:
import numpy as np
import matplotlib.pyplot as plt
data = np.random.random((10,10))
fig, ax = plt.subplots()
im = ax.imshow(data, cmap='gist_earth', alpha=0.5)
cbar = fig.colorbar(im)
cbar.solids.set(alpha=1)
plt.show()

On a side note, if you were working with a transparent contour
instead of contourf
, you might want to modify the alpha
value of all of cbar.lines
, as well.