Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mark a specific level in contour map on matplotlib

Can anyone give me an example of how to mark a specific level in a contour map? I would like to mark the level which is the black line in this plot:

Contour map in which I want to mark a level

I am using the following code:

plt.figure()

CS = plt.contour(X, Y,log_mu,levels = [np.log10(5e-8),np.log10(9e-5)])
CS = plt.contourf(X, Y,log_mu)
CB = plt.colorbar(CS, shrink=0.8, extend='both')

plt.xscale('log')
plt.yscale('log')

plt.show()

And the data for this specific plot can be obtained here dpaste data for contour plot

like image 937
Ohm Avatar asked Jun 25 '14 21:06

Ohm


1 Answers

Take a look at this example from the matplotlib gallery for contour plot functionality. By modifying the levels in your script, as well as changing some of the references, leads to :

plt.figure()

CS = plt.contour(X, Y,log_mu,levels = [-7,-8],
                 colors=('k',),linestyles=('-',),linewidths=(2,))
CSF = plt.contourf(X, Y,log_mu)
plt.clabel(CS, fmt = '%2.1d', colors = 'k', fontsize=14) #contour line labels
CB = plt.colorbar(CSF, shrink=0.8, extend='both')

plt.xscale('log')
plt.yscale('log')

plt.show()

enter image description here

like image 55
mtadd Avatar answered Oct 17 '22 15:10

mtadd