Labels

Wednesday, May 8, 2019

Plot contour/scatter figure by matplotlib

This is my code.

import matplotlib.pyplot as plt
import matplotlib.tri as tri
import numpy as np

x,y,z = np.loadtxt('GRID007.dat',unpack=True)
#plt.tricontourf(x,y,z,np.linspace(int(min(z)),120,30,endpoint=True))
#plt.colorbar(ticks=range(int(min(z)),130,10))
''' plt.tricontourf(x,y,z,[min(z),37,74,111])
'''
plt.scatter(x,y,c=z,vmax=120)
plt.plot(1.07204,0.762,color='red',linestyle="None",marker='*',label=r'best fit ($\chi^2=100$')
#plt.legend()
#plt.colorbar(ticks=[min(z),111,222,333])
plt.colorbar()
plt.savefig(filename='scatter007.pdf',format='pdf',dpi=300)
plt.show()

No comments:

Post a Comment