Missing levels in python contour plot
<p>I am trying to plot contours with specified levels of a simulated velocity field, my values are in the range of [75,150], and I specified my levels to be <code>levels=[75,95,115,135,150]</code>,but it's only giving me the 95,115,135 lines. I checked my 2d array and I do have points with values of 75 and 150 lying on straight lines, but the plot is just not showing them. I am wondering why would that be the case. Thanks a lot!!
Here is my code:</p>

<pre><code>import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse

#some parameters...does not matter 
i=60*np.pi/180 #inclination
r=100 #radius
vc=150
vr=0

x=np.arange(-100,100,1)
y=np.arange(-100,100,1)

xx,yy=np.meshgrid(x,y)

#simulate velocity fields....does not matter either
def projv((x, y),v_c, v_r, inc):
   projvy = v_c*x*np.cos(inc)/np.sqrt(x**2+y**2) + v_r*y*np.cos(inc)/np.sqrt(x**2+y**2)
   projvx = v_c*y/np.sqrt(x**2+y**2) + v_r*x/np.sqrt(x**2+y**2)
   v = np.sqrt(projvx**2 + projvy**2)
   return v.ravel()

 #here is my 2d array
 vel = projv((xx,yy),vc, vr, i).reshape(200,200)

#levels I specified
levels=[75,95,115,135,150]
cs=plt.contour(x,y,vel,levels)
plt.clabel(cs,inline=1,fontsize=9)
plt.show()
</code></pre>

<p>Then I got this:<a href="http://i.stack.imgur.com/1exAh.png" rel="nofollow"><img src="http://i.stack.imgur.com/1exAh.png" alt="This is not showing the 75 and 150 contour levels that I specified. Why?"></a></p>

<p>You are missing the 75 and 150 contours because those values are never crossed in the array. The value 150 exists, and the value 75(.000000000000014) exist, but those are the min and max values. Contours describe a line/surface <strong>boundary</strong>.</p>

<pre><code>#levels modified
levels=[76,95,115,135,149]
cs=plt.contour(x,y,vel,levels)
plt.clabel(cs,inline=1,fontsize=9)
</code></pre>

<p><a href="http://i.stack.imgur.com/APVfF.png" rel="nofollow"><img src="http://i.stack.imgur.com/APVfF.png" alt="with modified levels"></a></p>

python matplotlib contour