In [1]:import matplotlib.pyplot as plt import numpy as np In [2]:%matplotlib inline In [3]:x=np.array([1,2,3,4]) y=np.array([3,5,4,7]) plt.plot(x,y) Out[3]:[] In [4]:plt.scatter(x,y) Out[4]: In [5]:fig,axes = plt.subplots(1,2) axes[0].plot(x,y) axes[1].scatter(x,y) Out[5]: In [6]:fig,axes = plt.subplots(2,2,figsize=(12,5)) axes[0,0].plot(x,y) axes[1,0].plot(x,y) axes[0,1].scatter(x,y) axes[1,1].scatter(x,y) Out[6]: In [7]:x = np.linspace(-5,5,300) y1 = np.sin(x) y2 = np.cos(x) plt.plot(x,y1) plt.plot(x,y2) Out[7]:[] In [8]:plt.fill_between(x,y1,y2,where=y1>=y2,color="r") plt.fill_between(x,y1,y2,where=y1 In [9]:plt.plot(x,y1,label="sin") plt.plot(x,y2,label="cos") plt.title("Graph of sin and cos") plt.ylim(-2,2) plt.xticks(np.arange(-5,5.01,1)) plt.yticks(np.arange(-2,2.01,0.25)) plt.annotate("peek of sin",xy=(np.pi/2,1),xytext=(1,1.5), arrowprops={"arrowstyle":"->"}) plt.legend() Out[9]: In [10]:fig,ax1 = plt.subplots(figsize=(5,6)) width = 0.8 x = np.arange(1,13) precipitation = np.array([85, 57, 103, 120, 137.5, 174.5, 81.5, 414, 287, 96.5, 139, 84]) temperature = np.array([6.1, 7.2, 10.1, 15.4, 20.2, 22.4, 25.4, 27.1, 24.4, 18.7, 11.4, 8.9]) ax1.bar(x, precipitation, width, color="g") ax1.set_ylim(0,600) ax1.set_xticks(x) ax2 = ax1.twinx() ax2.set_ylim(-20,40) ax2.plot(x,temperature, color="r") Out[10]:[] In [11]:np.random.seed(0) x = np.random.randn(500) plt.hist(x, bins=20) Out[11]:(array([ 5., 2., 7., 7., 21., 24., 35., 45., 53., 55., 47., 52., 42., 38., 22., 14., 12., 10., 8., 1.]), array([-2.77259276, -2.49915192, -2.22571108, -1.95227024, -1.67882939, -1.40538855, -1.13194771, -0.85850687, -0.58506603, -0.31162519, -0.03818435, 0.23525649, 0.50869733, 0.78213817, 1.05557901, 1.32901985, 1.60246069, 1.87590153, 2.14934237, 2.42278321, 2.69622405]), ) In [12]:def f(x,y): return np.exp(-(x**2+y**2))+np.exp(-((x-2)**2+(y-2)**2)) x = np.linspace(-1,3,200) y = np.linspace(-1,3,200) X,Y = np.meshgrid(x,y) Z = f(X.ravel(),Y.ravel()).reshape(X.shape) plt.contourf(X,Y,Z) Out[12]: