matplotlib
matplotlib
[6]: x = np.random.rand(50)
y = np.random.rand(50)
[7]: x
[8]: y
1
[12]: df = pd.DataFrame(np.random.randn(1000), columns = ['data'], index = pd.
↪date_range('2023-03-29', periods =1000))
2
[15]: x = [1,2,3,4,5]
y = [9,5,6,7,8]
plt.plot(x,y)
[18]: plt.plot(x,y)
plt.title("line plot to understand the syntax")
plt.xlabel("x points")
plt.ylabel("y points")
3
[19]: plt.plot(x,y)
plt.title("line plot to understand the syntax")
plt.xlabel("x points")
plt.ylabel("y points")
plt.show()
4
[23]: plt.plot(x,y, color = "red")
plt.title("line plot to understand the syntax")
plt.xlabel("x points")
plt.ylabel("y points")
plt.show()
5
[25]: plt.plot(x,y, color = "red", marker = "o")
plt.title("line plot to understand the syntax")
plt.xlabel("x points")
plt.ylabel("y points")
plt.show()
6
[26]: plt.plot(x,y, color = "red", marker = "o", linestyle = '--')
plt.title("line plot to understand the syntax")
plt.xlabel("x points")
plt.ylabel("y points")
plt.show()
7
[27]: plt.plot(x,y, color = "red", marker = "o", linestyle = '--', linewidth = 3)
plt.title("line plot to understand the syntax")
plt.xlabel("x points")
plt.ylabel("y points")
plt.show()
8
[28]: plt.plot(x,y, color = "red", marker = "o", linestyle = '--', linewidth = 3,␣
↪markersize = 7)
9
[31]: plt.plot(x,y, color = "red", marker = "o", linestyle = '--', linewidth = 3,␣
↪markersize = 7)
10
[37]: x = [1,2,3,4,5]
y1= [9,5,6,7,8]
y2= [9,8,12,7,8]
plt.title("line to understand")
plt.show()
11
[38]: x = [1,2,3,4,5]
y1= [9,5,6,7,8]
y2= [9,8,12,7,8]
plt.title("line to understand")
plt.legend()
plt.show()
12
[39]: x = np.linspace(0,10,100)
[40]: x
13
8.08080808, 8.18181818, 8.28282828, 8.38383838, 8.48484848,
8.58585859, 8.68686869, 8.78787879, 8.88888889, 8.98989899,
9.09090909, 9.19191919, 9.29292929, 9.39393939, 9.49494949,
9.5959596 , 9.6969697 , 9.7979798 , 9.8989899 , 10. ])
14
[43]: plt.plot(x, np.sin(x),'--')
15
[46]: plt.figure()
plt.subplot(1,2,1)
plt.plot(x, np. sin(x))
plt.figure()
plt.subplot(4,5,1)
plt.plot(x, np. cos(x))
plt.show()
16
[47]: plt.figure()
plt.subplot(2,2,1)
plt.plot(x, np. sin(x))
plt.figure()
plt.subplot(4,4,4)
plt.plot(x, np. cos(x))
plt.figure()
plt.subplot(1,2,1)
17
plt.plot(x, np. tan(x))
plt.figure()
plt.subplot(2,5,1)
plt.plot(x, np. cos(x+1))
plt.show()
plt.show()
18
[48]: plt.plot(x, np. sin(x-0),color = "blue")
plt.plot(x, np. sin(x-1),color = "g")
plt.plot(x, np. sin(x-2),color = (1.0,0.5,0))
19
[49]: plt.plot(x, np. sin(x-0),color = "blue")
plt.ylim(1,2,3,4)
plt.xlim(0.5,0.10,0.15,0.20)
plt.show()
20
[51]: x = [1,2,3,4,5]
y = [9,5,6,7,8]
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[51], line 4
1 x = [1,2,3,4,5]
2 y = [9,5,6,7,8]
----> 4 plt.plot(x, np. sin(x-0),color = "blue")
5 plt.ylim(1,2,3,4,5,6)
6 plt.xlim(5,10,15,8)
[ ]:
21