def plot_2D_contour(states,p,labels,inter=False):
import pylab as pl
from pyme.statistics import expectation as EXP
exp = EXP((states,p))
X = np.unique(states[0,:])
Y = np.unique(states[1,:])
X_len = len(X)
Y_len = len(Y)
Z = np.zeros((X.max()+1,Y.max()+1))
for i in range(len(p)):
Z[states[0,i],states[1,i]] = p[i]
Z = np.where(Z < 1e-8,0.0,Z)
pl.clf()
XX, YY = np.meshgrid(X,Y)
pl.contour(range(X.max()+1),range(Y.max()+1),Z.T)
pl.axhline(y=exp[1])
pl.axvline(x=exp[0])
pl.xlabel(labels[0])
pl.ylabel(labels[1])
if inter == True:
pl.draw()
else:
pl.show()
评论列表
文章目录