2

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:enter image description here But I want to change the color of it, to get the figure like thisenter image description here How can I set the color?

1 Answer 1

2

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.

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.