I am trying to plot this figure and I cannot figure out how to get rid of the whitespace at the edge. Also, I want to remove the red and have it start on the orange, giving it only 5 contour levels. As I adjust the settings, it links the colorbar to the scale. I still want the red to be in the colorbar. What am I doing wrong?
import numpy as np
import matplotlib.pyplot as plt
from IPython.display import Image
from IPython.core.display import HTML
z = np.load('heights.npy')
nx, ny = np.shape(z)
plt.contour(np.transpose(z),np.linspace(z.min(),z.max(),7), colors='black')
plt.contourf(np.transpose(z),np.linspace(z.min(),z.max(),7))
plt.colorbar(orientation='horizontal')
plt.xlim(0, nx)
plt.ylim(0, ny)
plt.set_cmap('jet')
plt.savefig('pc3.png', format='png', bbox_inches=0)
plt.close()
Image(url='pc3.png')