matplotlib
April 24, 2024
[10]: import pandas as pd
import numpy as np
import [Link] as plt
[6]: x = [Link](50)
y = [Link](50)
[7]: x
[7]: array([0.30209178, 0.36465146, 0.6517227 , 0.64217784, 0.18394955,
0.43992628, 0.97284552, 0.44464244, 0.73957774, 0.85068249,
0.59514177, 0.59043099, 0.96952162, 0.63557871, 0.10673337,
0.12619059, 0.55984256, 0.54137774, 0.975966 , 0.83401489,
0.30622566, 0.65870933, 0.7956874 , 0.53831361, 0.28125521,
0.08301803, 0.06846407, 0.77602031, 0.09198045, 0.87324448,
0.45952519, 0.83970149, 0.98286191, 0.33175433, 0.94585855,
0.90141068, 0.99288648, 0.03855211, 0.38754614, 0.17746932,
0.30905146, 0.75663492, 0.72290799, 0.46104689, 0.1298827 ,
0.43302667, 0.53864503, 0.78307543, 0.03724502, 0.49931759])
[8]: y
[8]: array([0.36763653, 0.64688348, 0.89869257, 0.05024984, 0.79321601,
0.03710734, 0.8674068 , 0.77215801, 0.99895439, 0.528465 ,
0.72186661, 0.39146745, 0.01891229, 0.59990627, 0.40357562,
0.25447947, 0.8132269 , 0.10533152, 0.19602344, 0.56766765,
0.96943092, 0.68680141, 0.12110709, 0.43979179, 0.46963497,
0.46638116, 0.92031331, 0.71507098, 0.14622799, 0.78520582,
0.93304859, 0.55832187, 0.04519302, 0.5238949 , 0.9955732 ,
0.4405559 , 0.88289017, 0.44201191, 0.63381631, 0.96928366,
0.15281517, 0.69783284, 0.85963521, 0.51254292, 0.89863094,
0.06013336, 0.21766704, 0.10266528, 0.5514191 , 0.45001613])
[9]: [Link](x,y)# to understand the two variable
[9]: <[Link] at 0x7f1ac50dcbb0>
1
[12]: df = [Link]([Link](1000), columns = ['data'], index = pd.
↪date_range('2023-03-29', periods =1000))
[13]: [Link](figsize = (20,8))
[13]: <AxesSubplot: >
2
[15]: x = [1,2,3,4,5]
y = [9,5,6,7,8]
[Link](x,y)
[15]: [<[Link].Line2D at 0x7f0c58578bb0>]
[18]: [Link](x,y)
[Link]("line plot to understand the syntax")
[Link]("x points")
[Link]("y points")
3
[19]: [Link](x,y)
[Link]("line plot to understand the syntax")
[Link]("x points")
[Link]("y points")
[Link]()
4
[23]: [Link](x,y, color = "red")
[Link]("line plot to understand the syntax")
[Link]("x points")
[Link]("y points")
[Link]()
5
[25]: [Link](x,y, color = "red", marker = "o")
[Link]("line plot to understand the syntax")
[Link]("x points")
[Link]("y points")
[Link]()
6
[26]: [Link](x,y, color = "red", marker = "o", linestyle = '--')
[Link]("line plot to understand the syntax")
[Link]("x points")
[Link]("y points")
[Link]()
7
[27]: [Link](x,y, color = "red", marker = "o", linestyle = '--', linewidth = 3)
[Link]("line plot to understand the syntax")
[Link]("x points")
[Link]("y points")
[Link]()
8
[28]: [Link](x,y, color = "red", marker = "o", linestyle = '--', linewidth = 3,␣
↪markersize = 7)
[Link]("line plot to understand the syntax")
[Link]("x points")
[Link]("y points")
[Link]()
9
[31]: [Link](x,y, color = "red", marker = "o", linestyle = '--', linewidth = 3,␣
↪markersize = 7)
[Link]("line plot to understand the syntax")
[Link]("x points")
[Link]("y points")
[Link]()
[Link]()
10
[37]: x = [1,2,3,4,5]
y1= [9,5,6,7,8]
y2= [9,8,12,7,8]
[Link](x,y1, color = "red", marker = "o", linestyle = '--', linewidth = 3,␣
↪markersize = 7,label = 'line y1')
[Link](x,y2, color = "b", marker = "o", linestyle = '--', linewidth = 3,␣
↪markersize = 10, label = 'line y2')
[Link]("x data axis")
[Link]("y data axis")
[Link]("line to understand")
[Link]()
11
[38]: x = [1,2,3,4,5]
y1= [9,5,6,7,8]
y2= [9,8,12,7,8]
[Link](x,y1, color = "red", marker = "o", linestyle = '--', linewidth = 3,␣
↪markersize = 7,label = 'line y1')
[Link](x,y2, color = "b", marker = "o", linestyle = '--', linewidth = 3,␣
↪markersize = 10, label = 'line y2')
[Link]("x data axis")
[Link]("y data axis")
[Link]("line to understand")
[Link]()
[Link]()
12
[39]: x = [Link](0,10,100)
[40]: x
[40]: array([ 0. , 0.1010101 , 0.2020202 , 0.3030303 , 0.4040404 ,
0.50505051, 0.60606061, 0.70707071, 0.80808081, 0.90909091,
1.01010101, 1.11111111, 1.21212121, 1.31313131, 1.41414141,
1.51515152, 1.61616162, 1.71717172, 1.81818182, 1.91919192,
2.02020202, 2.12121212, 2.22222222, 2.32323232, 2.42424242,
2.52525253, 2.62626263, 2.72727273, 2.82828283, 2.92929293,
3.03030303, 3.13131313, 3.23232323, 3.33333333, 3.43434343,
3.53535354, 3.63636364, 3.73737374, 3.83838384, 3.93939394,
4.04040404, 4.14141414, 4.24242424, 4.34343434, 4.44444444,
4.54545455, 4.64646465, 4.74747475, 4.84848485, 4.94949495,
5.05050505, 5.15151515, 5.25252525, 5.35353535, 5.45454545,
5.55555556, 5.65656566, 5.75757576, 5.85858586, 5.95959596,
6.06060606, 6.16161616, 6.26262626, 6.36363636, 6.46464646,
6.56565657, 6.66666667, 6.76767677, 6.86868687, 6.96969697,
7.07070707, 7.17171717, 7.27272727, 7.37373737, 7.47474747,
7.57575758, 7.67676768, 7.77777778, 7.87878788, 7.97979798,
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. ])
[41]: [Link](x, [Link](x))
[Link](x, [Link](x))
[41]: [<[Link].Line2D at 0x7f0c549b3b20>]
[42]: [Link](x, [Link](x))
[42]: [<[Link].Line2D at 0x7f0c54999780>]
14
[43]: [Link](x, [Link](x),'--')
[43]: [<[Link].Line2D at 0x7f0c54a22170>]
15
[46]: [Link]()
[Link](1,2,1)
[Link](x, np. sin(x))
[Link]()
[Link](4,5,1)
[Link](x, np. cos(x))
[Link]()
16
[47]: [Link]()
[Link](2,2,1)
[Link](x, np. sin(x))
[Link]()
[Link](4,4,4)
[Link](x, np. cos(x))
[Link]()
[Link](1,2,1)
17
[Link](x, np. tan(x))
[Link]()
[Link](2,5,1)
[Link](x, np. cos(x+1))
[Link]()
[Link]()
18
[48]: [Link](x, np. sin(x-0),color = "blue")
[Link](x, np. sin(x-1),color = "g")
[Link](x, np. sin(x-2),color = (1.0,0.5,0))
[48]: [<[Link].Line2D at 0x7f0c54629030>]
19
[49]: [Link](x, np. sin(x-0),color = "blue")
[Link](1,2,3,4)
[Link](0.5,0.10,0.15,0.20)
[Link]()
/tmp/ipykernel_1666/[Link]: MatplotlibDeprecationWarning: Passing the
emit parameter of set_ylim() positionally is deprecated since Matplotlib 3.6;
the parameter will become keyword-only two minor releases later.
[Link](1,2,3,4)
/tmp/ipykernel_1666/[Link]: MatplotlibDeprecationWarning: Passing the
emit parameter of set_xlim() positionally is deprecated since Matplotlib 3.6;
the parameter will become keyword-only two minor releases later.
[Link](0.5,0.10,0.15,0.20)
20
[51]: x = [1,2,3,4,5]
y = [9,5,6,7,8]
[Link](x, np. sin(x-0),color = "blue")
[Link](1,2,3,4,5,6)
[Link](5,10,15,8)
[Link]()
---------------------------------------------------------------------------
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 [Link](x, np. sin(x-0),color = "blue")
5 [Link](1,2,3,4,5,6)
6 [Link](5,10,15,8)
TypeError: unsupported operand type(s) for -: 'list' and 'int'
[ ]:
21