0

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')

enter image description here

Brian B.
  • 111
  • 2
  • 10
  • Can you add or link the input data file, so we can reproduce the problem? –  Oct 21 '15 at 02:05
  • 1
    I suspect that you can solve the whitespace issue by setting your limits differently: `plt.xlim(0, nx-1); plt.ylim(0, nx-1)`. –  Oct 21 '15 at 02:14
  • Your color question should be a different question, but: do you want to change the red in the figure into orange? Or do you want to change the levels so that red automatically becomes orange? Or do you simply not want to color the red area? There's a bunch of options, and it's not clear which one you'd like. But as said, that's more another question. –  Oct 21 '15 at 02:17
  • I want to remove the red area, so it starts with orange, keeping the other colors. – Brian B. Oct 21 '15 at 02:18
  • Futher on the colors: [this question](http://stackoverflow.com/questions/3373256/set-colorbar-range-in-matplotlib?rq=1) (which was simply linked in my related bar, so wasn't too hard to find) may solve your second issue. –  Oct 21 '15 at 02:19

0 Answers0