In [1]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

using meshgrid to compute functions on a 2d grid

In [2]:
xlin = np.arange(-5,5,0.1) # 1d array
ylin = np.arange(-5,5,0.1) # 1d array
xm,ym = np.meshgrid(xlin,ylin) # 2d arrays
In [5]:
xm.shape
Out[5]:
(100, 100)
In [3]:
plt.imshow(ym)
Out[3]:
<matplotlib.image.AxesImage at 0x7ff229f086d0>
In [4]:
z = np.sin(xm**2 + 0.5*ym**2)
In [6]:
plt.imshow(z)
plt.colorbar()
Out[6]:
<matplotlib.colorbar.Colorbar at 0x7ff22a0ce310>
In [7]:
plt.contourf(xlin,ylin,z)
plt.colorbar()
Out[7]:
<matplotlib.colorbar.Colorbar at 0x7ff228186100>

Why it is a good idea to post code on github (or similar website)

https://github.com/

software licenses: why it is a good idea to choose one when you post code

https://choosealicense.com/

In [ ]: