python pyplot negative contour lines not displayed

1.3k Views Asked by At
minr=min(r_s)
maxr=max(r_s)
mini=min(i_s)
maxi=max(i_s)

xi=np.arange(minr,maxr, 0.1)
yi=np.arange(mini,maxi, 0.1)

zi=mlab.griddata(r_s, i_s, r_z, xi, yi, interp='linear')

plt.rcParams['contour.negative_linestyle'] = 'dashed'
CS=plt.contour(xi,yi,zi,50, linewidths =2.0)

plt.clabel(CS, inline=1, fontsize=10)
CS = plt.contourf(xi,yi,zi,15,cmap=plt.cm.rainbow)
plt.colorbar()

plt.xlabel('RS')
plt.ylabel('IS') 
plt.show()
print ("END")

The above code is written to display a contour map of scattered 3D points r_s, i_s, r_z. I was able to plot the contour map/lines but only positive contour lines are displayed. Am I missing something? I want to show many contour lines including the negative ones.

data varies as follows: r_s: from -7 to 2.0 with a step of 0.1 i_s: from -3 to 15 with a step of 0.1 r_z: from -1100 to 400 randomly

1

There are 1 best solutions below

0
On BEST ANSWER

I was able to find a solution to my problem. The code is fine. The problem is in the data. In fact, some data points (few points) were above 10^6 which forced the contour plot not to show the negative points (about -1000). After fixing the data, I was able to plot contour lines including negative contour lines with the above code.