Reputation: 135
I have the following code:
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()
And I got the figure: But I want to change the color of it, to get the figure like this How can I set the color?
Upvotes: 2
Views: 11601
Reputation: 65430
You need to specify the jet
colormap when creating the pcolor
object
pylab.pcolor(v, r, z, cmap='jet')
That being said, the jet
colormap isn't ideal for many situations so take care to choose an appropriate colormap.
Upvotes: 2