matplotlib1 - Jupyter Notebook
matplotlib1 - Jupyter Notebook
0.0
0.1
0.2
0.30000000000000004
0.4
0.5
0.6000000000000001
0.7000000000000001
0.8
0.9
1.0
1.8181818181818183
2.6363636363636367
3.4545454545454546
4.272727272727273
5.090909090909091
5.909090909090909
6.7272727272727275
7.545454545454546
8.363636363636363
9.181818181818182
10.0
In [12]: x=[1,2,3,4,5]
y=[2,3,2,3,2]
print(x)
print(y)
[1, 2, 3, 4, 5]
[2, 3, 2, 3, 2]
localhost:8888/notebooks/Documents/arun/mathsprogram/matplotlib.ipynb 1/5
11/28/23, 2:57 PM matplotlib - Jupyter Notebook
In [11]: plot(x,y,'o')
In [ ]: #draw a graph of avg annual temperature from yr 2000 to 2012 which are
#53.9,56.3,56.4,53.4,54.5,55.8,56.8,55.0,55.3,54.0,56.7,56.4,57.3
In [15]: yr=[2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012]
avg_temp=[53.9,56.3,56.4,53.4,54.5,55.8,56.8,55.0,55.3,54.0,56.7,56.4,57.3]
print(avg_temp)
print(yr)
[53.9, 56.3, 56.4, 53.4, 54.5, 55.8, 56.8, 55.0, 55.3, 54.0, 56.7, 56.4, 5
7.3]
[2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2
012]
In [17]: plot(yr,avg_temp,marker='o')
localhost:8888/notebooks/Documents/arun/mathsprogram/matplotlib.ipynb 2/5
11/28/23, 2:57 PM matplotlib - Jupyter Notebook
In [18]: plot(yr,avg_temp,marker='*')
In [ ]:
localhost:8888/notebooks/Documents/arun/mathsprogram/matplotlib.ipynb 3/5
11/28/23, 2:57 PM matplotlib - Jupyter Notebook
In [34]: x=np.linspace(0,2*np.pi,200)
y=np.sin(x)
plt.plot(x,y)
localhost:8888/notebooks/Documents/arun/mathsprogram/matplotlib.ipynb 4/5
11/28/23, 2:57 PM matplotlib - Jupyter Notebook
In [42]: x=np.linspace(0,2*np.pi,200)
y=np.sin(x)
z=np.cos(x)
plt.subplot(2,2,1)
plt.title("Sinx")
plt.plot(x,y)
plt.subplot(2,1,2)
plt.title("Cosx")
plt.plot(x,z)
In [ ]:
localhost:8888/notebooks/Documents/arun/mathsprogram/matplotlib.ipynb 5/5