我有以下代码:
import matplotlib.pyplot as plt
import numpy as np
from scipy import integrate, special
import pylab
def f(v,r):
""" Initial function"""
alpha = 0.2
chi = 1/2*special.erf((r+1.2)/0.3)-1/2*special.erf((r-1.2)/0.3)
return 4/(np.sqrt(2*np.pi*alpha))*chi*np.exp(-v**2/(2*alpha))
N_xi = 100
v = (np.arange(N_xi)*4/(N_xi - 1)-2)
r = (np.arange(N_xi)*4/(N_xi - 1)-2)
z = f(v.reshape(-1, 1), r.reshape(1, -1))
pylab.pcolor(v, r, z)
pylab.colorbar()
pylab.show()
答案 0 :(得分:1)
pylab.pcolor(v, r, z, cmap='jet')
话虽如此,jet
色彩图在许多情况下并不理想,所以请注意choose an appropriate colormap。