I am trying to save a matplotlib.colorbar plot as an image file, jpg or png. I have tried the two ways written in the code below.
Using clb.savefig results in the error:
AttributeError: 'Colorbar' object has no attribute 'savefig'
using plt.savefig saves in a blank image without the plot.
import matplotlib.pyplot as plt
plt.scatter(X,Y,c=Z, cmap='gnuplot2')
clb = plt.colorbar()
clb.savefig('name.jpg')
plt.savefig('name.jpg')
Is there something I'm missing? How to save a Colorbar plot as an image?