Simple plotting commands to look at data quickly
from matplotlib.pyplot import plot
plot([1, 2, 3], [2, 4, 6])
[<matplotlib.lines.Line2D at 0x7fcafecce160>]
import matplotlib.pyplot as plt
from matplotlib import style
plt.plot([1, 2, 3], [2, 4, 6])
[<matplotlib.lines.Line2D at 0x7fcb137fd580>]
plt.plot([1, 2, 3], [2, 4, 6])
plt.show()
x = [1, 2, 3]
y = [2, 4, 6]
plt.plot(x, y)
plt.show()
x = [1, 2, 3]
y = [2, 4, 6]
plt.plot(x, y)
plt.title('Straight Line')
plt.show()
x = [1, 2, 3]
y = [2, 4, 6]
plt.plot(x, y)
plt.title('Straight Line', fontdict={"fontname": "Times New Roman", "fontsize":20})
plt.show()
x = [1, 2, 3]
y = [2, 4, 6]
plt.plot(x, y)
plt.title('Straight Line', fontdict={"fontname": "Times New Roman", "fontsize":20})
plt.xlabel("X Asix", fontdict={"fontname": "Comic Sans MS", "fontsize": 20})
plt.show()
x = [0, 1, 2, 3, 4]
y = [0, 2, 4, 6, 8]
plt.plot(x, y)
plt.title('Straight Line', fontdict={"fontname": "Times New Roman", "fontsize":20})
plt.xlabel("X Asix", fontdict={"fontname": "Comic Sans MS", "fontsize": 20})
plt.xticks([0, 1, 2, 3, 4])
plt.yticks([0, 2, 4, 6, 8, 10])
plt.show()
x = [0, 1, 2, 3, 4]
y = [0, 2, 4, 6, 8]
plt.plot(x, y)
plt.title('Straight Line', fontdict={"fontname": "Times New Roman", "fontsize":20})
plt.xlabel("X Asix", fontdict={"fontname": "Comic Sans MS", "fontsize": 20})
plt.xlabel("X Asix", fontdict={"fontname": "Comic Sans MS", "fontsize": 20})
plt.xticks([0, 1, 2, 3, 3.5, 4])
plt.yticks([0, 2, 4, 6, 8, 8.5, 9, 10])
plt.show()
x = [0, 1, 2, 3, 4]
y = [0, 2, 4, 6, 8]
x1 = array([0, 1, 2, 3, 4])
y1 = array([0, 2, 4, 6, 8])
plt.plot(x, y, label = "$y = 2x$")
plt.title('Straight Line', fontdict={"fontname": "Times New Roman", "fontsize":20})
plt.xlabel("X Asix", fontdict={"fontname": "Comic Sans MS", "fontsize": 20})
plt.xlabel("X Asix", fontdict={"fontname": "Comic Sans MS", "fontsize": 20})
plt.xticks([0, 1, 2, 3, 3.5, 4])
plt.yticks([0, 2, 4, 6, 8, 8.5, 9, 10])
plt.legend()
plt.show()
x = [0, 1, 2, 3, 4]
y = [0, 2, 4, 6, 8]
plt.plot(x, y ** 2, label = "$y = x^2$")
plt.title('Straight Line', fontdict={"fontname": "Times New Roman", "fontsize":20})
plt.xlabel("X Asix", fontdict={"fontname": "Comic Sans MS", "fontsize": 20})
plt.xlabel("X Asix", fontdict={"fontname": "Comic Sans MS", "fontsize": 20})
plt.xticks([0, 1, 2, 3, 3.5, 4])
plt.yticks([0, 2, 4, 6, 8, 8.5, 9, 10])
plt.legend()
plt.show()
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) /var/folders/dw/p9lncvq57tv4px69pk911vl40000gn/T/ipykernel_901/2953554774.py in <module> 2 y = [0, 2, 4, 6, 8] 3 ----> 4 plt.plot(x, y ** 2, label = "$y = x^2$") 5 plt.title('Straight Line', fontdict={"fontname": "Times New Roman", "fontsize":20}) 6 plt.xlabel("X Asix", fontdict={"fontname": "Comic Sans MS", "fontsize": 20}) TypeError: unsupported operand type(s) for ** or pow(): 'list' and 'int'
x1 = array([0, 1, 2, 3, 4])
y1 = array([0, 2, 4, 6, 8])
plt.plot(x1, y1 ** 2, label = "$y = x^2$")
plt.title('Straight Line', fontdict={"fontname": "Times New Roman", "fontsize":20})
plt.xlabel("X Asix", fontdict={"fontname": "Comic Sans MS", "fontsize": 20})
plt.xlabel("X Asix", fontdict={"fontname": "Comic Sans MS", "fontsize": 20})
plt.xticks([0, 1, 2, 3, 3.5, 4])
plt.yticks([0, 2, 4, 6, 8, 8.5, 9, 10])
plt.legend()
plt.show()
x1 = array([0, 1, 2, 3, 4])
y1 = array([0, 2, 4, 6, 8])
plt.plot(x1, y1 ** 2, label = "$y = x^2$")
plt.title('Straight Line', fontdict={"fontname": "Times New Roman", "fontsize":20})
plt.xlabel("X Asix", fontdict={"fontname": "Comic Sans MS", "fontsize": 20})
plt.xlabel("X Asix", fontdict={"fontname": "Comic Sans MS", "fontsize": 20})
plt.xticks([0, 1, 2, 3, 3.5, 4])
plt.yticks([0, 4, 16, 36, 64, 56.25, 81, 100])
plt.legend()
plt.show()
x = [0, 1, 2, 3, 4]
y = [0, 2, 4, 6, 8]
plt.plot(x, y, label = "$y = 2x$", color= '#2af6a5', marker = '.', linestyle = "dashdot" , markersize = 10, \
markeredgecolor="#dd3947")
plt.title('Straight Line', fontdict={"fontname": "Times New Roman", "fontsize":20})
plt.xlabel("X Asix", fontdict={"fontname": "Comic Sans MS", "fontsize": 20})
plt.xlabel("X Asix", fontdict={"fontname": "Comic Sans MS", "fontsize": 20})
plt.xticks([0, 1, 2, 3, 3.5, 4])
plt.yticks([0, 2, 4, 6, 8, 8.5, 9, 10])
plt.legend()
plt.show()
labels = ['A', 'B', 'C']
values = [1, 4, 2]
plt.bar(labels, values)
plt.show()
labels = ['A', 'B', 'C']
values = [1, 4, 2]
plt.figure(figsize=(6,4))
bars = plt.bar(labels, values)
bars[0].set_hatch('/')
bars[1].set_hatch('o')
bars[2].set_hatch('*')
plt.show()
labels = ['A', 'B', 'C']
values = [1, 4, 2]
plt.figure(figsize=(6,4))
bars = plt.bar(labels, values)
paterns = ['/', 'o', '*']
for bar in bars:
bar.set_hatch(paterns.pop(0))
# bars[0].set_hatch('/')
# bars[1].set_hatch('o')
# bars[2].set_hatch('*')
plt.show()
labels = ['A', 'B', 'C']
values = [1, 4, 2]
plt.figure(figsize=(6,4))
bars = plt.bar(labels, values)
paterns = ['/', 'o', '*']
for bar in bars:
bar.set_hatch(paterns.pop())
# bars[0].set_hatch('/')
# bars[1].set_hatch('o')
# bars[2].set_hatch('*')
plt.show()
x = np.linspace(0,15,30)
y = np.sin(x) + 0.1*np.random.randn(len(x))
x
array([ 0. , 0.51724138, 1.03448276, 1.55172414, 2.06896552,
2.5862069 , 3.10344828, 3.62068966, 4.13793103, 4.65517241,
5.17241379, 5.68965517, 6.20689655, 6.72413793, 7.24137931,
7.75862069, 8.27586207, 8.79310345, 9.31034483, 9.82758621,
10.34482759, 10.86206897, 11.37931034, 11.89655172, 12.4137931 ,
12.93103448, 13.44827586, 13.96551724, 14.48275862, 15. ])
y
array([ 0.02981107, 0.55286175, 0.814338 , 0.96260674, 0.86756382,
0.52510829, -0.08335135, -0.52690874, -0.72357951, -0.99606741,
-0.71195337, -0.50130289, -0.17623514, 0.36274456, 0.69582955,
0.93660238, 0.97448074, 0.43590578, 0.05903551, -0.34580148,
-0.83620259, -0.92615519, -1.18514135, -0.34079546, -0.15822537,
0.50811401, 0.78945142, 0.91518241, 0.90104908, 0.80752386])
np.random.rand(len(x))
array([0.06460702, 0.42107375, 0.27613102, 0.77306782, 0.36642744,
0.62934932, 0.47778023, 0.18659001, 0.81884021, 0.9200216 ,
0.7648626 , 0.11784263, 0.15006604, 0.10967121, 0.62527486,
0.98538797, 0.4975219 , 0.07423203, 0.21770794, 0.75467839,
0.7095082 , 0.1356839 , 0.08203238, 0.76342986, 0.29198362,
0.80817945, 0.5909613 , 0.64050741, 0.30678636, 0.83130118])
len(x)
30
np.random.rand(1)
array([0.95514031])
np.random.rand(3)
array([0.27887584, 0.43397946, 0.10683499])
np.random.rand(30)
array([0.82548641, 0.74193505, 0.41554649, 0.45472931, 0.93463585,
0.12121709, 0.97314183, 0.59022656, 0.26035456, 0.65089384,
0.56376054, 0.44438056, 0.45718615, 0.40794219, 0.67726283,
0.78338543, 0.25311743, 0.23305277, 0.81471944, 0.79554439,
0.22916447, 0.13877519, 0.30641603, 0.98376895, 0.10030124,
0.67945965, 0.14550494, 0.36007792, 0.21213761, 0.02921576])
np.random.rand(len(x))
array([0.12773702, 0.42104591, 0.11871246, 0.35652773, 0.3946626 ,
0.47624334, 0.56938587, 0.20512452, 0.12015803, 0.71931095,
0.85032943, 0.19521646, 0.21198957, 0.29101547, 0.3958043 ,
0.04597919, 0.75948722, 0.90484102, 0.38966744, 0.82187083,
0.42049989, 0.82380348, 0.33116278, 0.45808617, 0.54382573,
0.62394608, 0.66134566, 0.63921516, 0.32245382, 0.90889006])
plt.style.use(['science', 'notebook', 'grid'])
print(plt.style.available)
['Solarize_Light2', '_classic_test_patch', 'bmh', 'bright', 'cjk-jp-font', 'cjk-kr-font', 'cjk-sc-font', 'cjk-tc-font', 'classic', 'dark_background', 'fast', 'fivethirtyeight', 'ggplot', 'grayscale', 'grid', 'high-contrast', 'high-vis', 'ieee', 'latex-sans', 'light', 'muted', 'nature', 'no-latex', 'notebook', 'pgf', 'retro', 'scatter', 'science', 'seaborn', 'seaborn-bright', 'seaborn-colorblind', 'seaborn-dark', 'seaborn-dark-palette', 'seaborn-darkgrid', 'seaborn-deep', 'seaborn-muted', 'seaborn-notebook', 'seaborn-paper', 'seaborn-pastel', 'seaborn-poster', 'seaborn-talk', 'seaborn-ticks', 'seaborn-white', 'seaborn-whitegrid', 'std-colors', 'tableau-colorblind10', 'vibrant']
plt.plot(x,y)
[<matplotlib.lines.Line2D at 0x7fcb036515b0>]
plt.style.use(['default'])
plt.plot(x,y)
[<matplotlib.lines.Line2D at 0x7fcb041dd100>]
plt.style.use(['science', 'notebook', 'grid'])
plt.plot(x,y)
[<matplotlib.lines.Line2D at 0x7fcb04279cd0>]
plt.plot(x,y, "-")
[<matplotlib.lines.Line2D at 0x7fcb044c2fd0>]
plt.plot(x,y, "--")
[<matplotlib.lines.Line2D at 0x7fcb040fefd0>]
plt.plot(x,y, "o-")
[<matplotlib.lines.Line2D at 0x7fcb01531760>]
plt.plot(x,y, "o")
[<matplotlib.lines.Line2D at 0x7fcb009fca00>]
plt.plot(x,y, "o--")
[<matplotlib.lines.Line2D at 0x7fcafa5789d0>]
plt.plot(x,y, "o--", color="purple")
[<matplotlib.lines.Line2D at 0x7fcb00e2e850>]
plt.plot(x,y, "o--", color="purple", lw=0.1)
[<matplotlib.lines.Line2D at 0x7fcaf532abe0>]
plt.plot(x,y, "o--", color="purple", lw=0.5)
[<matplotlib.lines.Line2D at 0x7fcb013b68e0>]
plt.plot(x,y, "o--", color="purple", lw=4)
[<matplotlib.lines.Line2D at 0x7fcb00d8dc70>]
plt.plot(x,y, "o--", color="purple", lw=0.7)
[<matplotlib.lines.Line2D at 0x7fcb01299d90>]
plt.plot(x,y, 'o--', color='purple', lw=2, ms=10)
[<matplotlib.lines.Line2D at 0x7fcafa3fddc0>]
plt.plot(x,y, 'o--', color='purple', lw=2, ms=0.1)
[<matplotlib.lines.Line2D at 0x7fcb0077ba60>]
plt.plot(x,y, 'o--', color='purple', lw=2, ms=5)
[<matplotlib.lines.Line2D at 0x7fcae5c262e0>]
plt.figure(figsize=(8,3))
plt.plot(x,y, 'o--', color='purple', lw=2, ms=5)
[<matplotlib.lines.Line2D at 0x7fcae5cc5730>]
plt.figure(figsize=(4,3))
plt.plot(x,y, 'o--', color='purple', lw=2, ms=5)
[<matplotlib.lines.Line2D at 0x7fcae5f55730>]
plt.figure(figsize=(10,3))
plt.plot(x,y, 'o--', color='purple', lw=2, ms=5)
[<matplotlib.lines.Line2D at 0x7fcae687d6a0>]
plt.style.use(['science', 'notebook', 'grid'])
plt.figure(figsize=(10,3))
plt.plot(x,y, 'o--', color='purple', lw=2, ms=5)
plt.xlabel('Time(s)')
plt.ylabel('Voltage(V)')
Text(0, 0.5, 'Voltage(V)')
plt.figure(figsize=(10,3))
plt.plot(x,y, 'o--', color='purple', lw=2, ms=5)
plt.xlabel('Time(s)', fontsize=10)
plt.ylabel('Voltage(V)', fontsize=10)
Text(0, 0.5, 'Voltage(V)')
plt.figure(figsize=(8,3))
plt.plot(x,y, 'o--', color='purple', lw=2, ms=5)
plt.xlabel('Time(s)', fontsize=16)
plt.ylabel('Voltage(V)', fontsize=16)
plt.title('Voltage in 3rd Electrode')
Text(0.5, 1.0, 'Voltage in 3rd Electrode')
plt.figure(figsize=(8,3))
plt.plot(x,y, 'o--', color='gold', lw=2, ms=5)
plt.xlabel('Time(s)', fontsize=16)
plt.ylabel('Voltage(V)', fontsize=16)
plt.title('Voltage in 3rd Electrode', fontsize=20)
Text(0.5, 1.0, 'Voltage in 3rd Electrode')
plt.figure(figsize=(8,3))
plt.plot(x,y, 'o--', color='gold', lw=2, ms=5, label='Numerical curve')
plt.xlabel('Time(s)', fontsize=16)
plt.ylabel('Voltage(V)', fontsize=16)
plt.title('Voltage in 3rd Electrode', fontsize=20)
plt.legend()
<matplotlib.legend.Legend at 0x7fcb00748dc0>
plt.figure(figsize=(8,3))
plt.plot(x,y, 'o--', color='gold', lw=2, ms=5, label='Numerical curve')
plt.xlabel('Time(s)', fontsize=16)
plt.ylabel('Voltage(V)', fontsize=16)
plt.title('Voltage in 3rd Electrode', fontsize=20)
plt.legend(fontsize=10)
<matplotlib.legend.Legend at 0x7fcae7cba4c0>
plt.figure(figsize=(8,3))
plt.plot(x,y, 'o--', color='red', lw=2, ms=5, label='Numerical curve')
plt.xlabel('Time(s)', fontsize=16)
plt.ylabel('Voltage(V)', fontsize=16)
plt.title('Voltage in 3rd Electrode', fontsize=20)
plt.legend(fontsize=10, loc="upper left")
<matplotlib.legend.Legend at 0x7fcae793e2b0>
plt.figure(figsize=(8,3))
plt.plot(x,y, 'o--', color='red', lw=2, ms=5, label='Numerical curve')
plt.xlabel('Time(s)', fontsize=16)
plt.ylabel('Voltage(V)', fontsize=16)
plt.title('Voltage in 3rd Electrode', fontsize=20)
plt.legend(fontsize=10, loc="lower right")
<matplotlib.legend.Legend at 0x7fcae81c5730>
plt.figure(figsize=(8,3))
plt.plot(x,y, 'o--', color='red', lw=2, ms=5, label='Numerical curve')
plt.xlabel('Time(s)', fontsize=16)
plt.ylabel('Voltage(V)', fontsize=16)
plt.title('Voltage in 3rd Electrode', fontsize=20)
plt.legend(fontsize=10, loc="center")
<matplotlib.legend.Legend at 0x7fcb004cf7f0>
plt.figure(figsize=(8,3))
plt.plot(x,y, 'o--', color='red', lw=2, ms=5, label='Numerical curve')
plt.xlabel('Time(s)', fontsize=16)
plt.ylabel('Voltage(V)', fontsize=16)
plt.title('Voltage in 3rd Electrode', fontsize=20)
plt.legend(fontsize=10, loc=(0,0))
<matplotlib.legend.Legend at 0x7fcae84b3670>
plt.figure(figsize=(8,3))
plt.plot(x,y, 'o--', color='red', lw=2, ms=5, label='Numerical curve')
plt.xlabel('Time(s)', fontsize=16)
plt.ylabel('Voltage(V)', fontsize=16)
plt.title('Voltage in 3rd Electrode', fontsize=20)
plt.legend(fontsize=10, loc=(1,1))
<matplotlib.legend.Legend at 0x7fcae86b2850>
plt.figure(figsize=(8,3))
plt.plot(x,y, 'o--', color='red', lw=2, ms=5, label='Numerical curve')
plt.xlabel('Time(s)', fontsize=16)
plt.ylabel('Voltage(V)', fontsize=16)
plt.title('Voltage in 3rd Electrode', fontsize=20)
plt.legend(fontsize=10, loc=(0.2, 0.4))
<matplotlib.legend.Legend at 0x7fcae88b9940>
x2 = np.linspace(0, 15, 100)
y2 = np.sin(x2)
plt.figure(figsize=(8,3))
plt.plot(x,y, 'o--', color='red', lw=2, ms=5, label='Numerical curve')
plt.xlabel('Time(s)', fontsize=16)
plt.ylabel('Voltage(V)', fontsize=16)
plt.title('Voltage in 3rd Electrode', fontsize=20)
plt.legend(fontsize=10, loc=(0.2, 0.4))
plt.plot(x2,y2, label='Numerical Curve 2')
plt.legend(loc='lower right', fontsize=12)
plt.show()
plt.figure(figsize=(8,3))
plt.plot(x,y, 'o', color='red', lw=2, ms=5, label='Numerical curve')
plt.xlabel('Time(s)', fontsize=16)
plt.ylabel('Voltage(V)', fontsize=16)
plt.title('Voltage in 3rd Electrode', fontsize=20)
plt.legend(fontsize=10, loc=(0.2, 0.4))
plt.plot(x2,y2, label='Numerical Curve 2')
plt.legend(loc='lower right', fontsize=12)
plt.show()
plt.figure(figsize=(8,3))
plt.plot(x,y, 'o', color='red', lw=2, ms=5, label='Numerical curve', zorder = 1) # adding zorder
plt.xlabel('Time(s)', fontsize=16)
plt.ylabel('Voltage(V)', fontsize=16)
plt.title('Voltage in 3rd Electrode', fontsize=20)
plt.legend(fontsize=10, loc=(0.2, 0.4))
plt.plot(x2,y2, label='Numerical Curve 2', zorder = 0) # adding zoder
plt.legend(loc='lower right', fontsize=12)
plt.show()
plt.figure(figsize=(8,3))
plt.plot(x,y, 'o', color='red', lw=2, ms=5, label='Numerical curve', zorder = 0) # adding zorder
plt.xlabel('Time(s)', fontsize=16)
plt.ylabel('Voltage(V)', fontsize=16)
plt.title('Voltage in 3rd Electrode', fontsize=20)
plt.legend(fontsize=10, loc=(0.2, 0.4))
plt.plot(x2,y2, label='Numerical Curve 2', zorder = 1) # adding zoder
plt.legend(loc='lower right', fontsize=12)
plt.show()
## Legend in 2 column an 1 row
plt.figure(figsize=(8,3))
plt.plot(x,y, 'o', color='red', lw=2, ms=5, label='Numerical curve', zorder = 1) # adding zorder
plt.xlabel('Time(s)', fontsize=16)
plt.ylabel('Voltage(V)', fontsize=16)
plt.title('Voltage in 3rd Electrode', fontsize=20)
plt.legend(fontsize=10, loc=(0.2, 0.4))
plt.plot(x2,y2, label='Numerical Curve 2', zorder = 0) # adding zoder
plt.legend(loc='lower right', fontsize=12, ncol=2)
plt.show()
plt.figure(figsize=(8,3))
plt.plot(x,y, 'o', color='red', lw=2, ms=5, label='Numerical curve', zorder = 1) # adding zorder
plt.xlabel('Time(s)', fontsize=16)
plt.ylabel('Voltage(V)', fontsize=16)
plt.title('Voltage in 3rd Electrode', fontsize=20)
plt.legend(fontsize=10, loc=(0.2, 0.4))
plt.plot(x2,y2, label='Numerical Curve 2', zorder = 0) # adding zoder
plt.legend(loc='lower right', fontsize=12, ncol = 2)
plt.ylim(bottom = - 2)
(-2.0, 1.1089340254494993)
plt.figure(figsize=(8,3))
plt.plot(x,y, 'o', color='red', lw=2, ms=5, label='Numerical curve', zorder = 1) # adding zorder
plt.xlabel('Time(s)', fontsize=16)
plt.ylabel('Voltage(V)', fontsize=16)
plt.title('Voltage in 3rd Electrode', fontsize=20)
plt.legend(fontsize=10, loc=(0.2, 0.4))
plt.plot(x2,y2, label='Numerical Curve 2', zorder = 0) # adding zoder
plt.legend(loc='lower right', fontsize=12, ncol = 2)
plt.ylim(bottom = - 2)
plt.ylim(top = 2)
(-2.0, 2.0)
plt.figure(figsize=(8,3))
plt.plot(x,y, 'o', color='red', lw=2, ms=5, label='Numerical curve', zorder = 1) # adding zorder
plt.xlabel('Time(s)', fontsize=16)
plt.ylabel('Voltage(V)', fontsize=16)
plt.title('Voltage in 3rd Electrode', fontsize=20)
plt.legend(fontsize=10, loc=(0.2, 0.4))
plt.plot(x2,y2, label='Numerical Curve 2', zorder = 0) # adding zoder
plt.legend(loc='lower right', fontsize=12, ncol = 2)
plt.ylim(bottom = - 2)
plt.ylim(top = 2)
plt.xlim(left = - 1)
plt.xlim(right = 16)
(-1.0, 16.0)
res = np.random.randn(1000)*0.2 + 0.4
res
array([ 5.37955235e-01, 9.63451698e-02, 3.04462388e-02, 7.22901636e-01,
1.97477962e-01, 2.28331311e-01, 1.88601040e-01, 3.03974964e-01,
6.61342709e-01, 5.05026047e-01, 5.23552944e-01, 2.69813715e-01,
5.31953609e-01, 3.80274217e-01, 6.40778053e-01, 3.46193741e-01,
3.10332311e-01, 4.87320207e-01, 2.97444251e-01, 5.72153725e-01,
5.75476219e-01, 3.92910178e-01, 4.43344751e-01, 2.27889124e-01,
3.51804067e-01, 4.33927161e-01, 3.23781502e-01, 7.15048185e-01,
4.36803975e-01, 3.97854253e-01, 3.33593696e-01, 5.10075496e-01,
2.76606603e-01, 2.25495311e-02, 5.09278301e-01, 2.14278206e-01,
3.84380553e-01, 3.98849262e-01, 4.23205203e-01, 3.68288719e-01,
1.69300649e-01, 7.85101357e-01, 1.09844240e-02, 5.55053884e-01,
7.04972988e-01, 4.67422886e-01, 3.97442521e-01, 3.44192484e-01,
1.60635730e-01, 5.52384995e-02, 5.46152360e-01, 4.05225754e-01,
3.22856786e-01, 1.82522770e-01, 5.31382442e-01, 5.83154895e-01,
4.88518677e-02, 1.79158897e-01, 5.96986160e-01, 4.44449340e-01,
4.71847946e-01, 4.30751729e-01, 4.40408579e-01, 3.75898661e-01,
3.55385190e-01, 5.93774303e-01, 4.25145822e-01, 7.27679541e-01,
5.67875955e-01, 5.88542602e-01, 2.80567396e-01, 3.48740020e-01,
4.16500058e-01, 4.39773953e-01, 7.62981947e-01, 1.28364102e-01,
5.55889836e-01, 3.35349839e-01, 5.20642229e-01, 4.36002040e-01,
3.53070900e-01, 3.40658103e-01, 3.31757481e-01, 3.30889129e-01,
3.69245926e-01, 5.54683124e-01, 3.24492586e-01, 1.89789381e-01,
4.30663806e-01, 1.97793265e-01, 9.62979713e-01, 2.58197553e-01,
4.51321478e-01, 4.78471419e-01, 6.20036944e-01, 1.01914709e-01,
1.97272861e-01, 1.90630088e-01, 2.75617689e-01, 2.61353365e-01,
3.69085249e-01, -5.69788650e-02, 5.73079805e-01, 1.84707819e-01,
3.12156178e-01, 5.26125851e-01, 5.07976981e-01, 3.74739002e-01,
4.51301988e-01, 8.82345233e-01, 3.31686224e-01, 2.11443173e-01,
5.91352158e-01, 7.17900433e-01, 4.93331231e-01, 4.44264802e-01,
-1.99098915e-01, 7.74473713e-01, 4.61853530e-01, 1.08457239e-01,
6.39035338e-01, 3.76769679e-01, 5.62440126e-01, 7.62013991e-01,
1.90048210e-01, 3.97314222e-01, 1.78487823e-01, 4.09992571e-01,
1.48788437e-01, 4.01722579e-01, 2.80819059e-01, 4.42696767e-01,
4.42742541e-01, 4.67133688e-01, 5.66200780e-01, 3.96304092e-01,
5.24394348e-01, 5.98876530e-01, 3.22760081e-01, 1.32210901e-01,
3.07831540e-02, 1.62924197e-01, 3.44119477e-01, 5.70013627e-01,
3.94434682e-01, 2.39640772e-01, 2.21935471e-01, 3.91534653e-01,
4.57941058e-01, 4.07050849e-01, 6.13324436e-01, 3.02875102e-01,
5.93605341e-01, -2.96178501e-02, 2.91139895e-01, 6.23596250e-01,
2.06174519e-01, 7.02363709e-01, 2.31256171e-01, 2.19553010e-01,
3.76008844e-01, 3.67828532e-01, 7.34912279e-01, 5.19244162e-01,
4.46637267e-01, 4.97051569e-01, 3.86568042e-01, 4.44110210e-01,
2.83985400e-01, 4.64762497e-01, 5.79108403e-01, 2.02016135e-01,
8.04076214e-01, 3.85987076e-01, 4.43991561e-01, 5.36137200e-01,
-4.19243140e-05, -1.50691040e-01, 5.27409339e-01, 7.84180557e-01,
6.14467207e-01, 4.53176509e-01, 2.80314952e-01, 2.80644154e-01,
4.24360848e-01, 5.15233971e-01, 5.95470527e-01, 4.12179963e-01,
2.18266915e-01, 3.77146997e-01, 5.67840582e-01, 3.87399205e-01,
4.60120148e-01, 3.49632096e-01, 3.68075262e-01, 3.59568840e-01,
3.67952975e-01, 3.18210497e-01, 2.71359146e-01, 6.80286292e-01,
2.99785038e-01, 7.46595028e-01, 3.76168244e-01, 1.38496587e-01,
6.33215827e-01, 6.96116898e-01, 5.18381200e-01, 3.34522098e-01,
3.03491168e-01, 6.09027620e-01, 4.06670309e-01, 3.16600437e-01,
5.18023000e-01, 5.38066632e-01, -1.59826731e-02, 8.83715548e-02,
3.08259221e-01, 3.41987484e-01, 2.22648206e-01, 4.39263114e-01,
1.52815566e-01, 3.65594151e-01, 3.51344878e-01, 9.49002097e-02,
5.08239531e-01, 8.44717044e-02, 5.00388448e-01, 1.65989621e-01,
2.53859774e-01, 4.70984469e-01, 4.62285346e-01, 3.23118612e-01,
4.10315817e-01, 2.96082507e-01, 7.24442862e-02, 3.95475202e-01,
6.14104731e-01, 4.15300271e-01, 4.72313402e-01, 2.08998613e-01,
4.14458075e-01, 4.95153102e-01, 5.77959173e-01, 7.47234037e-01,
3.36291497e-01, 2.78677408e-01, 6.41933551e-01, 7.16865891e-01,
5.54979393e-01, 1.50594438e-01, 3.25182028e-01, 4.53150784e-01,
3.88885361e-01, 5.43276771e-01, 5.21447471e-01, 1.41618917e-02,
6.68631753e-01, 1.17595805e-01, 4.46888237e-01, 2.29419350e-01,
2.76959396e-01, 6.28088304e-01, 1.71542151e-01, 5.63409694e-01,
3.94856803e-01, 3.35100841e-01, 8.71882884e-01, 3.41925525e-01,
5.45013882e-01, 3.18479768e-01, 3.99001217e-01, 5.09965075e-01,
6.09990084e-01, 5.53843433e-01, 6.91686397e-01, 2.24218040e-01,
5.80683304e-01, 4.57967882e-01, 4.46211096e-01, 5.01894019e-01,
-1.28768533e-01, 6.25587413e-01, 4.20071554e-01, 4.13798570e-01,
4.07129359e-01, 2.14246838e-01, 1.74452421e-01, 3.59177937e-01,
1.77670023e-01, 6.21385790e-01, 3.13538034e-01, 6.69856722e-01,
2.90454902e-01, 2.82012365e-01, 5.43962901e-01, 3.76734578e-01,
3.63540259e-01, 8.04828166e-01, 5.90772145e-02, 1.05596601e-03,
5.07346316e-01, 6.13527452e-01, 6.80863427e-01, 7.26066091e-01,
3.01528437e-01, 3.01293295e-01, 7.32507374e-01, 3.41495069e-01,
3.43811218e-01, 2.75910502e-01, 2.47263409e-01, 4.40850954e-01,
4.62487448e-01, 4.05943693e-01, 4.34012363e-01, 6.71961424e-01,
4.41229431e-01, -2.37171376e-02, 4.95075988e-01, 5.85923536e-01,
3.44881640e-01, 1.39976052e-01, 4.08104577e-01, 4.94700944e-01,
2.94584702e-01, 3.17790153e-01, 1.15149808e-01, 2.39241511e-01,
4.47396001e-01, 5.53474041e-01, 7.47456148e-01, 8.20893508e-01,
1.79785531e-01, 3.21703208e-01, 8.18960890e-01, 4.77114610e-01,
7.40140914e-01, 3.92677042e-01, 3.92373943e-01, 5.56893290e-01,
5.93285624e-01, 4.92582050e-01, 7.08918274e-01, 4.41168972e-01,
6.02632801e-01, 2.02908778e-01, 3.60878618e-01, 2.26083399e-01,
7.16178037e-01, 4.89645050e-01, 3.13365409e-01, 5.52248176e-01,
3.15359394e-01, 4.60151273e-01, 6.48931940e-01, 3.60904965e-01,
6.95265348e-01, 5.28346238e-01, 1.84287239e-01, 3.65192605e-01,
4.06899252e-01, 3.72179346e-01, 6.32453442e-01, 1.11655295e-01,
6.34235647e-02, 1.41886500e-01, -5.55268445e-02, 5.72365624e-01,
1.58356382e-01, 7.80100369e-01, 2.88964398e-01, 9.88694770e-01,
5.06091937e-01, 2.52158574e-01, 4.89756720e-01, 5.48582315e-01,
4.15771206e-01, 5.60008895e-01, 5.37757917e-01, 3.73781268e-01,
1.26821746e-01, 5.26099345e-01, 5.00207296e-01, 4.84325370e-01,
1.29501000e-01, 3.58374279e-01, 3.40542868e-01, 7.99273931e-01,
6.73617097e-01, 9.71930147e-02, 4.27644583e-01, 5.50916815e-01,
-1.67794524e-01, 6.37816162e-01, 6.96289987e-01, 4.32178862e-01,
2.55545188e-01, 4.58557075e-01, 3.77905216e-01, 5.59917901e-01,
6.42681518e-01, 7.53702345e-01, 6.50702191e-01, 1.72767550e-01,
1.35591049e-02, 3.35620621e-01, 9.54987689e-02, 5.25420957e-01,
2.80252189e-01, 4.62545811e-01, 3.00417881e-01, 3.59979363e-01,
4.86398051e-01, 4.75541279e-01, 5.04901868e-01, 1.39546248e-01,
3.16029592e-01, 6.58433164e-01, 2.56954076e-01, 3.79851891e-01,
4.41860603e-01, 6.02439462e-02, 7.94876816e-01, 6.17775350e-01,
5.57721179e-01, 7.19299999e-01, 5.38023822e-01, 3.59482861e-01,
5.02307507e-01, 6.20460170e-01, 1.71609171e-01, 4.92070255e-01,
3.07486521e-01, 4.81910735e-01, 1.60855267e-01, 4.13450648e-01,
3.74164306e-01, 5.72455176e-01, 7.18076186e-01, 8.26422024e-01,
2.60529119e-01, 3.69263536e-01, 5.88935500e-01, 4.98637281e-01,
4.55208972e-01, 3.83383660e-01, 5.29319829e-01, 3.81235768e-01,
2.19622078e-01, 5.27963525e-01, 2.09855540e-01, 3.45511675e-01,
3.68494560e-01, 5.70452078e-01, 2.78011859e-01, 5.26898716e-01,
4.51324814e-01, 2.52730155e-01, 3.88613651e-01, 5.36676196e-01,
4.67416345e-01, 5.15035617e-02, 6.15966883e-01, -1.69180568e-01,
4.46305529e-01, 5.24450024e-01, 5.82094139e-01, 4.64896763e-01,
4.15873986e-01, 1.93749538e-01, 4.21159592e-01, 7.58736112e-01,
2.88833779e-01, 1.51468313e-01, 2.22362877e-01, 8.39692341e-02,
3.50150551e-01, 1.76934476e-01, 1.21412135e-01, 4.79531365e-01,
5.57882790e-01, 7.81754200e-01, 1.98002085e-01, 7.53810111e-01,
7.63718775e-01, 1.83461822e-01, 1.95751729e-01, 2.81545949e-01,
4.48856291e-01, 5.40862782e-01, 7.35596514e-01, 8.75431654e-02,
5.04063150e-01, 4.13164827e-01, 9.81016900e-02, 4.12913123e-01,
2.99547293e-01, 2.15068875e-01, 6.18557376e-01, 1.80010595e-01,
1.78806017e-01, 3.12550247e-01, 2.95500332e-01, 2.01167249e-01,
2.78188221e-01, 4.21540666e-01, 1.58660150e-01, 2.50653669e-01,
2.08975061e-01, 3.82452566e-01, 3.96196504e-01, 2.91066093e-01,
3.70690874e-01, 6.38994756e-01, 3.58067049e-01, 6.00003993e-01,
3.52424632e-01, 4.39174697e-01, 1.39017188e-01, 2.18950412e-01,
6.48677036e-01, 6.02809296e-01, 5.75089107e-01, 2.35797127e-01,
3.11421926e-01, 8.49328944e-02, -1.48253292e-02, 3.18366845e-01,
2.82221143e-01, 4.98087379e-01, 5.96273148e-01, 4.33187059e-01,
1.37749323e-01, 4.68301681e-01, 4.21217368e-01, 5.35228388e-01,
5.16977064e-01, 4.22218478e-01, 4.48393330e-01, 4.38451297e-01,
1.89796397e-01, 3.27192082e-01, 2.32321616e-01, 4.58412866e-01,
6.96169930e-01, 4.51472915e-01, 3.58494522e-01, 1.28435297e-01,
1.37877139e-01, 7.26159511e-01, 4.01406148e-01, 3.89285978e-01,
5.45824950e-01, 3.53145755e-01, 5.19242463e-01, 1.58894451e-01,
1.76351010e-01, 1.21208502e-01, 5.75085943e-01, 2.74016815e-01,
4.53812108e-01, 7.31034338e-01, 4.96298738e-01, 3.27919078e-01,
1.54948364e-01, 1.67306170e-01, 3.53008613e-01, 1.37472126e-01,
1.56732529e-01, 6.87568257e-01, 6.63413150e-01, 5.38611101e-01,
4.24717850e-01, 2.82712004e-01, 1.08735267e-01, 2.93973385e-01,
3.30800415e-01, 3.25454884e-01, 2.71615820e-01, 4.99737942e-01,
3.91742660e-01, 3.62665860e-01, 4.25268485e-02, 4.40012940e-01,
3.86175415e-01, 5.00620834e-01, 5.22639569e-01, 2.45471483e-01,
4.10001404e-01, 7.79748802e-01, 3.94836675e-01, 2.56245416e-01,
4.76375484e-01, 2.58718543e-01, 2.08199685e-01, 5.48853097e-01,
4.98033752e-01, 5.47193022e-01, 8.84593220e-01, 6.47433671e-01,
4.32392310e-01, 5.05307137e-01, 4.77774614e-01, 5.09545639e-01,
3.83562969e-01, 4.34507289e-01, 4.20619954e-01, 7.31458144e-01,
4.47896003e-01, 4.00733806e-01, 5.26456016e-01, 5.21026469e-01,
5.50608400e-01, 5.18241747e-01, 2.13456574e-01, 3.18289945e-01,
5.04701377e-01, 3.78608113e-01, 7.96270166e-02, 4.52374548e-01,
7.24068171e-01, 3.02094626e-01, 5.11877367e-01, 5.01368278e-01,
1.80436509e-01, 1.53914991e-01, 1.81366761e-01, 1.07822071e-01,
5.75229646e-01, 5.20540367e-01, 3.41045351e-01, 3.85205517e-01,
7.23726421e-01, 5.29812883e-01, 4.45008532e-01, 3.24618852e-01,
1.12519422e-01, 5.69166278e-01, 2.80827317e-01, 6.03485398e-02,
6.93648921e-01, 5.41534427e-01, 5.67469514e-01, 6.93294801e-01,
5.33778302e-01, 2.53891993e-01, 6.79392970e-01, 5.11634061e-01,
2.70380699e-01, 7.85841699e-02, 4.18347969e-01, 3.79024511e-01,
1.94543605e-01, 3.23354836e-01, 4.58360976e-01, 6.08017538e-01,
2.87004200e-01, 2.91303861e-01, 4.33882768e-01, 2.77948799e-01,
4.10755442e-01, 2.60098559e-01, 8.89742704e-01, 3.45773238e-01,
5.12436619e-01, 7.55641772e-01, 7.76310542e-02, 5.34277438e-01,
5.90237588e-01, 6.43689028e-01, 5.80229058e-01, 2.11302432e-01,
4.09501180e-01, 3.94494211e-01, 5.09887064e-01, 5.18189203e-01,
6.86188389e-01, 4.04301179e-01, 3.00668371e-01, 3.43752248e-01,
5.59045579e-01, 4.72277778e-01, 6.70129862e-01, 2.59012821e-01,
3.98184532e-01, 3.82759414e-01, 9.19610353e-01, 5.87339494e-01,
5.97034753e-01, 3.44972183e-01, 3.50097835e-01, 6.99521451e-01,
3.95118615e-01, 5.43702558e-01, 4.91433329e-01, 2.33854455e-01,
7.75932867e-01, 2.87665153e-01, 1.85082743e-02, 3.72276742e-01,
5.58657501e-01, 3.18680087e-01, 2.54194544e-01, 2.96169889e-01,
4.27531504e-01, 3.15060617e-01, 2.59304436e-01, 3.53408816e-01,
5.52905042e-01, 3.79996117e-01, 2.14267193e-01, 3.17327726e-01,
4.22716137e-01, 2.30439231e-01, 6.68665794e-01, 4.10231536e-01,
4.13493885e-01, 4.11524218e-01, 3.99202784e-01, -1.28583788e-02,
5.61601648e-01, -2.52480245e-02, 6.95209471e-01, 2.66345560e-01,
9.01955154e-01, 2.61876858e-01, 2.60896427e-01, 5.57047548e-01,
4.07121410e-01, 2.79073449e-01, 1.82028046e-01, 3.77488496e-01,
4.21144149e-01, 4.06764568e-01, 3.40217860e-01, 3.76454433e-01,
5.96088997e-01, 1.65787060e-01, 3.42851704e-01, 4.32899828e-01,
1.12152330e-01, 7.26416059e-01, 2.00889719e-01, 4.11890873e-01,
7.03080173e-01, 4.10529240e-01, 4.49151693e-01, 4.35125633e-01,
-3.79442417e-02, 2.14657384e-01, 5.21577323e-01, 4.44859819e-01,
2.03496452e-01, 2.18723275e-01, 1.51310766e-01, 5.86955391e-01,
5.11166765e-01, 3.93128453e-01, 3.43363479e-01, 3.69944653e-01,
4.13513354e-01, 5.15979609e-01, 4.12060342e-01, 4.93542920e-01,
4.53291302e-01, 7.69541954e-02, 8.76212894e-02, 4.87412637e-01,
2.86488328e-01, 3.47038462e-01, 1.37287349e-01, 3.81110608e-01,
3.00531800e-01, 4.72604466e-01, 3.71634390e-01, 5.97549321e-01,
3.59135421e-01, 3.40748278e-01, 5.93873619e-01, 2.94591911e-01,
2.41149077e-01, 4.67911870e-01, 3.65061544e-01, 4.05242696e-01,
3.90809676e-01, 6.41412023e-01, 6.68950511e-01, 5.52765995e-01,
-5.58778419e-02, 2.85588199e-01, 4.78177495e-01, 4.77434544e-01,
7.76329514e-01, 2.75405105e-01, 3.65015402e-01, 5.22224347e-01,
2.96540582e-01, 4.54363972e-01, 2.48743032e-01, 3.88160545e-01,
2.80171676e-01, 8.31950146e-02, 7.05057914e-01, -4.37577125e-03,
3.78218588e-01, 2.32234017e-01, -1.98380046e-02, 5.67932172e-01,
6.44636869e-01, 8.98350594e-01, 2.47228561e-02, 2.39560735e-01,
-1.81126125e-02, 1.90979058e-01, 1.79943460e-01, 3.73709371e-01,
6.97991762e-01, 5.34464763e-01, 1.19230925e-01, 3.49451707e-01,
3.14849732e-01, 4.07971067e-02, 4.23111135e-01, 3.04590809e-01,
5.43613463e-01, 2.73069548e-01, 5.81558600e-01, 8.19177721e-01,
3.28697880e-01, 2.81195229e-01, 6.96201481e-01, 2.74244226e-01,
3.70276085e-01, 6.74722892e-01, 1.51791629e-01, 2.97190647e-01,
5.87930854e-01, 6.02048533e-01, 1.95835199e-01, 4.85124191e-01,
3.28750161e-01, 2.69533194e-01, 1.83202622e-01, 5.74830905e-01,
3.08784065e-01, 3.04422404e-01, 6.45447613e-01, 2.41987049e-01,
4.00159613e-01, 6.38575410e-01, 4.37321663e-01, 6.34578659e-01,
1.07236492e-01, 4.50917702e-01, 6.06205056e-01, 4.74612129e-01,
1.55971632e-01, 6.78258032e-01, 4.28830310e-01, 3.36377709e-01,
6.37299021e-01, 2.51693843e-01, 4.70864346e-01, 3.01361536e-01,
5.00906592e-01, 6.88036455e-01, 3.16375231e-01, 6.12411250e-01,
3.12855910e-01, 3.04815870e-01, 4.71945716e-01, 3.95436754e-02,
6.68406794e-01, 2.89708740e-01, 7.60536742e-01, 5.91932089e-01,
3.43720779e-01, -1.52189227e-01, 6.21231037e-01, 3.95858287e-01,
8.06952241e-01, 3.67164462e-01, 5.28300295e-01, 5.53907600e-01,
7.94923084e-01, 4.76201399e-01, 1.82139937e-01, 2.97019535e-01,
2.33751605e-01, 5.24674197e-01, 3.43705011e-01, 2.62697935e-01,
3.82698507e-01, 7.41474155e-01, 1.42372528e-01, 5.80079567e-01,
2.02567469e-01, 4.96327868e-01, 3.61260047e-01, 2.70944781e-01,
2.26158386e-01, 4.87114616e-01, 4.44822841e-01, 3.40248242e-01,
4.25253165e-01, 4.64761013e-01, 3.51793115e-01, 6.90738053e-01,
3.76836224e-01, 4.30421197e-01, 5.30352183e-01, 4.44564687e-01,
3.72114482e-01, 3.05191677e-01, 3.49832970e-01, 3.90899667e-01,
3.12178793e-01, 6.01148740e-01, 6.69939274e-01, 3.76127575e-01,
4.17484961e-01, 5.44075227e-01, 3.95880211e-01, 5.62845569e-01,
3.47859407e-01, 6.62758367e-01, 5.22426720e-01, 4.53479446e-01,
4.65075042e-01, 4.53900981e-01, -1.01657509e-01, 5.57254860e-01,
3.55560944e-01, 4.38527288e-01, 3.47810344e-01, 4.03104574e-01,
4.37793654e-01, 4.25172599e-01, 3.13301350e-01, 3.57487945e-01,
6.10482739e-01, 4.70420238e-01, 6.14024623e-01, 2.94362576e-01,
3.20913135e-01, 5.11657745e-01, 2.21821345e-01, 5.96613868e-01,
3.85096498e-01, 4.89048438e-01, -2.21229100e-01, 6.85253597e-01,
6.16936896e-01, 1.97885062e-01, 6.59220211e-01, 5.55065493e-01,
3.57267503e-01, 1.08446393e-01, 4.38533767e-01, 4.69073016e-01,
4.04083422e-01, 3.36719654e-01, 4.89408649e-01, 2.35142130e-01,
5.27982537e-01, 2.85332256e-01, 2.46120563e-01, 2.02140138e-01,
5.61641144e-01, 2.50402694e-01, 5.04093500e-01, 5.44387031e-01,
1.80213387e-02, 4.71900515e-01, 5.65142309e-01, 5.23171739e-01,
4.18356455e-01, 5.70672629e-01, 2.44603280e-01, 4.45923194e-01,
6.06338610e-01, 4.48853886e-01, 6.55244357e-01, 2.05566182e-01,
4.09445106e-01, 2.21427810e-01, 2.67729571e-01, 7.70835035e-02,
4.50739972e-01, 4.03566697e-01, 3.58126651e-01, 1.78777585e-01,
1.20008367e-01, 3.95031194e-01, 1.05815169e-01, 3.51734249e-01,
5.41820244e-01, 5.17234688e-01, 2.51713134e-01, 2.21864556e-01])
plt.hist(res)
(array([ 8., 20., 61., 138., 231., 240., 183., 82., 28., 9.]),
array([-0.2212291 , -0.10023671, 0.02075567, 0.14174806, 0.26274045,
0.38373284, 0.50472522, 0.62571761, 0.74671 , 0.86770238,
0.98869477]),
<BarContainer object of 10 artists>)
z = plt.hist(res)
z
(array([ 8., 20., 61., 138., 231., 240., 183., 82., 28., 9.]),
array([-0.2212291 , -0.10023671, 0.02075567, 0.14174806, 0.26274045,
0.38373284, 0.50472522, 0.62571761, 0.74671 , 0.86770238,
0.98869477]),
<BarContainer object of 10 artists>)
plt.hist(res, bins=2)
(array([458., 542.]), array([-0.2212291 , 0.38373284, 0.98869477]), <BarContainer object of 2 artists>)
plt.hist(res, bins=150)
(array([ 1., 0., 1., 0., 0., 0., 2., 0., 2., 0., 0., 1., 0.,
0., 1., 0., 0., 0., 0., 0., 3., 0., 1., 1., 3., 4.,
1., 2., 1., 4., 2., 2., 3., 2., 4., 1., 3., 7., 3.,
5., 7., 4., 5., 5., 8., 3., 9., 7., 6., 14., 10., 11.,
9., 10., 12., 8., 7., 8., 11., 13., 5., 15., 17., 13., 17.,
10., 21., 12., 10., 16., 21., 19., 12., 19., 24., 15., 22., 17.,
23., 14., 11., 20., 23., 19., 11., 18., 11., 7., 14., 15., 17.,
12., 21., 11., 15., 10., 17., 12., 12., 8., 10., 13., 7., 10.,
8., 3., 8., 8., 2., 5., 9., 5., 4., 11., 5., 1., 6.,
7., 5., 3., 4., 4., 2., 3., 5., 2., 1., 3., 2., 2.,
0., 0., 0., 0., 0., 1., 1., 2., 1., 1., 0., 1., 0.,
0., 0., 0., 1., 0., 0., 1.]),
array([-0.2212291 , -0.21316294, -0.20509678, -0.19703062, -0.18896446,
-0.1808983 , -0.17283214, -0.16476599, -0.15669983, -0.14863367,
-0.14056751, -0.13250135, -0.12443519, -0.11636903, -0.10830287,
-0.10023671, -0.09217055, -0.08410439, -0.07603824, -0.06797208,
-0.05990592, -0.05183976, -0.0437736 , -0.03570744, -0.02764128,
-0.01957512, -0.01150896, -0.0034428 , 0.00462336, 0.01268952,
0.02075567, 0.02882183, 0.03688799, 0.04495415, 0.05302031,
0.06108647, 0.06915263, 0.07721879, 0.08528495, 0.09335111,
0.10141727, 0.10948342, 0.11754958, 0.12561574, 0.1336819 ,
0.14174806, 0.14981422, 0.15788038, 0.16594654, 0.1740127 ,
0.18207886, 0.19014502, 0.19821118, 0.20627733, 0.21434349,
0.22240965, 0.23047581, 0.23854197, 0.24660813, 0.25467429,
0.26274045, 0.27080661, 0.27887277, 0.28693893, 0.29500508,
0.30307124, 0.3111374 , 0.31920356, 0.32726972, 0.33533588,
0.34340204, 0.3514682 , 0.35953436, 0.36760052, 0.37566668,
0.38373284, 0.39179899, 0.39986515, 0.40793131, 0.41599747,
0.42406363, 0.43212979, 0.44019595, 0.44826211, 0.45632827,
0.46439443, 0.47246059, 0.48052674, 0.4885929 , 0.49665906,
0.50472522, 0.51279138, 0.52085754, 0.5289237 , 0.53698986,
0.54505602, 0.55312218, 0.56118834, 0.5692545 , 0.57732065,
0.58538681, 0.59345297, 0.60151913, 0.60958529, 0.61765145,
0.62571761, 0.63378377, 0.64184993, 0.64991609, 0.65798225,
0.6660484 , 0.67411456, 0.68218072, 0.69024688, 0.69831304,
0.7063792 , 0.71444536, 0.72251152, 0.73057768, 0.73864384,
0.74671 , 0.75477616, 0.76284231, 0.77090847, 0.77897463,
0.78704079, 0.79510695, 0.80317311, 0.81123927, 0.81930543,
0.82737159, 0.83543775, 0.84350391, 0.85157006, 0.85963622,
0.86770238, 0.87576854, 0.8838347 , 0.89190086, 0.89996702,
0.90803318, 0.91609934, 0.9241655 , 0.93223166, 0.94029782,
0.94836397, 0.95643013, 0.96449629, 0.97256245, 0.98062861,
0.98869477]),
<BarContainer object of 150 artists>)
plt.hist(res, bins=150)
show()
plt.hist(res, bins=20)
(array([ 4., 4., 3., 17., 20., 41., 64., 74., 103., 128., 132.,
108., 109., 74., 42., 40., 24., 4., 7., 2.]),
array([-0.2212291 , -0.16073291, -0.10023671, -0.03974052, 0.02075567,
0.08125187, 0.14174806, 0.20224425, 0.26274045, 0.32323664,
0.38373284, 0.44422903, 0.50472522, 0.56522142, 0.62571761,
0.6862138 , 0.74671 , 0.80720619, 0.86770238, 0.92819858,
0.98869477]),
<BarContainer object of 20 artists>)
plt.figure(figsize=(8,3))
plt.hist(res, bins = 20)
(array([ 4., 4., 3., 17., 20., 41., 64., 74., 103., 128., 132.,
108., 109., 74., 42., 40., 24., 4., 7., 2.]),
array([-0.2212291 , -0.16073291, -0.10023671, -0.03974052, 0.02075567,
0.08125187, 0.14174806, 0.20224425, 0.26274045, 0.32323664,
0.38373284, 0.44422903, 0.50472522, 0.56522142, 0.62571761,
0.6862138 , 0.74671 , 0.80720619, 0.86770238, 0.92819858,
0.98869477]),
<BarContainer object of 20 artists>)
plt.figure(figsize=(8,3))
plt.hist(res, bins = 20, density = True) # Area under the histogram is now equal to one
(array([0.06611986, 0.06611986, 0.0495899 , 0.28100942, 0.33059931,
0.67772859, 1.0579178 , 1.22321746, 1.70258646, 2.1158356 ,
2.18195547, 1.78523629, 1.80176626, 1.22321746, 0.69425856,
0.66119863, 0.39671918, 0.06611986, 0.11570976, 0.03305993]),
array([-0.2212291 , -0.16073291, -0.10023671, -0.03974052, 0.02075567,
0.08125187, 0.14174806, 0.20224425, 0.26274045, 0.32323664,
0.38373284, 0.44422903, 0.50472522, 0.56522142, 0.62571761,
0.6862138 , 0.74671 , 0.80720619, 0.86770238, 0.92819858,
0.98869477]),
<BarContainer object of 20 artists>)
res2 = np.random.randn(1000)*0.2 + 0.4
plt.figure(figsize=(8,3))
plt.hist(res, bins = 20, density = True)
plt.hist(res2, bins = 20, density = True)
(array([0.03141243, 0.12564974, 0.25129948, 0.40836165, 0.65966113,
1.083729 , 1.31932226, 1.99468961, 1.83762744, 1.63344661,
1.85333366, 1.53920931, 1.24079118, 0.84813574, 0.47118652,
0.20418083, 0.0942373 , 0.03141243, 0.03141243, 0.04711865]),
array([-0.18536151, -0.12169245, -0.0580234 , 0.00564566, 0.06931471,
0.13298376, 0.19665282, 0.26032187, 0.32399092, 0.38765998,
0.45132903, 0.51499809, 0.57866714, 0.64233619, 0.70600525,
0.7696743 , 0.83334335, 0.89701241, 0.96068146, 1.02435051,
1.08801957]),
<BarContainer object of 20 artists>)
plt.figure(figsize=(8,3))
plt.hist(res, bins = 20, density = True, histtype="step")
plt.hist(res2, bins = 20, density = True, histtype="step")
(array([0.03141243, 0.12564974, 0.25129948, 0.40836165, 0.65966113,
1.083729 , 1.31932226, 1.99468961, 1.83762744, 1.63344661,
1.85333366, 1.53920931, 1.24079118, 0.84813574, 0.47118652,
0.20418083, 0.0942373 , 0.03141243, 0.03141243, 0.04711865]),
array([-0.18536151, -0.12169245, -0.0580234 , 0.00564566, 0.06931471,
0.13298376, 0.19665282, 0.26032187, 0.32399092, 0.38765998,
0.45132903, 0.51499809, 0.57866714, 0.64233619, 0.70600525,
0.7696743 , 0.83334335, 0.89701241, 0.96068146, 1.02435051,
1.08801957]),
[<matplotlib.patches.Polygon at 0x7fcaeb29a9a0>])
plt.figure(figsize=(8,3))
plt.hist(res, bins=30, density=True, histtype='step')
plt.hist(res2, bins=30, density=True, histtype='step')
plt.xlabel('$\hat{E}-E$', fontsize=20)
plt.ylabel('Frequency')
plt.show()
fig, ax = plt.subplots(1, 1, figsize=(12,4))
fig, ax = plt.subplots(1, 2, figsize=(12,4))
fig, ax = plt.subplots(1, 1, figsize=(12,4))
ax.plot(x, y, "o--")
[<matplotlib.lines.Line2D at 0x7fcae9344f70>]
fig, ax = plt.subplots(1, 1, figsize=(12,4))
ax.plot(x, y, "o--")
ax.set_xlabel("Time(s)")
ax.set_ylabel("Voltage(V)")
Text(0, 0.5, 'Voltage(V)')
fig, ax = plt.subplots(3, 2, figsize=(12,12))
ax.plot(x, y, "o--")
ax.set_xlabel("Time(s)")
ax.set_ylabel("Voltage(V)")
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) /var/folders/dw/p9lncvq57tv4px69pk911vl40000gn/T/ipykernel_901/79967231.py in <module> 1 fig, ax = plt.subplots(3, 2, figsize=(12,12)) ----> 2 ax.plot(x, y, "o--") 3 ax.set_xlabel("Time(s)") 4 ax.set_ylabel("Voltage(V)") AttributeError: 'numpy.ndarray' object has no attribute 'plot'
fig, axes = plt.subplots(3, 2, figsize=(12,12))
# ax.plot(x, y, "o--")
# ax.set_xlabel("Time(s)")
# ax.set_ylabel("Voltage(V)")
axes
array([[<AxesSubplot:>, <AxesSubplot:>],
[<AxesSubplot:>, <AxesSubplot:>],
[<AxesSubplot:>, <AxesSubplot:>]], dtype=object)
fig, axes = plt.subplots(3, 2, figsize=(12,12))
ax = axes[0][0]
ax.plot(x, y, "o--")
ax.set_xlabel("Time(s)")
ax.set_ylabel("Voltage(V)")
Text(0, 0.5, 'Voltage(V)')
fig, axes = plt.subplots(3, 2, figsize=(12,12))
ax = axes[0][0]
ax.plot(x, y, "o--")
ax.set_xlabel("Time(s)")
ax.set_ylabel("Voltage(V)")
ax = axes[1][1]
ax.hist(res2, bins=30, density=True, histtype='step')
ax.set_xlabel("Time(s)")
ax.set_ylabel("Voltage(V)")
Text(0, 0.5, 'Voltage(V)')
fig, axes = plt.subplots(3, 2, figsize=(12,12))
ax = axes[0][0]
ax.plot(x, y, "o--")
ax.set_xlabel("Time(s)")
ax.set_ylabel("Voltage(V)")
ax = axes[1][1]
ax.hist(res2, bins=30, density=True, histtype='step', label = "component 1") # Adding legend
ax.set_xlabel("Time(s)")
ax.set_ylabel("Voltage(V)")
ax.legend() # adding legend
<matplotlib.legend.Legend at 0x7fcaee1febe0>
fig, axes = plt.subplots(3, 2, figsize=(12,12))
ax = axes[0][0]
ax.plot(x, y, "o--")
ax.set_xlabel("Time(s)")
ax.set_ylabel("Voltage(V)")
ax = axes[1][1]
ax.hist(res2, bins=30, density=True, histtype='step', label = "component 1")
ax.set_xlabel("Time(s)")
ax.set_ylabel("Voltage(V)")
ax.set_title("Histogram") # Adding title
ax.legend()
<matplotlib.legend.Legend at 0x7fcaeb147610>
fig, axes = plt.subplots(3, 2, figsize=(12,12))
ax = axes[0][0]
ax.plot(x, y, "o--")
ax.set_xlabel("Time(s)")
ax.set_ylabel("Voltage(V)")
ax.text(0.1, 0.1, "Text") # adding text
ax = axes[1][1]
ax.hist(res2, bins=30, density=True, histtype='step', label = "component 1")
ax.set_xlabel("Time(s)")
ax.set_ylabel("Voltage(V)")
ax.set_title("Histogram")
ax.legend()
<matplotlib.legend.Legend at 0x7fcae9a9a4c0>
fig, axes = plt.subplots(3, 2, figsize=(12,12))
ax = axes[0][0]
ax.plot(x, y, "o--")
ax.set_xlabel("Time(s)")
ax.set_ylabel("Voltage(V)")
ax.text(0.1, 0.1, "Text", transform=ax.transAxes) # rescaling axes
ax = axes[1][1]
ax.hist(res2, bins=30, density=True, histtype='step', label = "component 1")
ax.set_xlabel("Time(s)")
ax.set_ylabel("Voltage(V)")
ax.set_title("Histogram")
ax.legend()
<matplotlib.legend.Legend at 0x7fcafeb81460>
fig, axes = plt.subplots(3, 2, figsize=(8,8))
ax = axes[0][0]
ax.plot(x, y, "o--")
ax.set_xlabel("Time(s)")
ax.set_ylabel("Voltage(V)")
ax.text(0.1, 0.1, "Text", transform=ax.transAxes) # rescaling axes
ax = axes[1][1]
ax.hist(res2, bins=30, density=True, histtype='step', label = "component 1")
ax.set_xlabel("Time(s)")
ax.set_ylabel("Voltage(V)")
ax.set_title("Histogram")
ax.legend()
fig.suptitle('Title of All Plots', y=0.95, fontsize=25)
Text(0.5, 0.95, 'Title of All Plots')
fig, axes = plt.subplots(3, 2, figsize=(12,12))
ax = axes[0][0]
ax.plot(x, y, "o--")
ax.set_xlabel("Time(s)")
ax.set_ylabel("Voltage(V)")
ax.text(0.1, 0.1, "Text", transform=ax.transAxes)
ax.tick_params(axis="both", labelsize=10) # resizing numbers of y-axes
ax = axes[1][1]
ax.hist(res2, bins=30, density=True, histtype='step', label = "component 1")
ax.set_xlabel("Time(s)")
ax.set_ylabel("Voltage(V)")
ax.set_title("Histogram")
ax.legend()
<matplotlib.legend.Legend at 0x7fcae9cd9130>
plt.style.use(['science', 'notebook', 'grid'])
fig, ax = plt.subplots(1, 1, figsize=(8,3))
ax.plot(x, y, 'o--', color='r', lw=1, ms=5)
ax.text(0.1, 0.1, 'text here', transform=ax.transAxes)
ax.set_xlabel('Time(s)')
ax.set_ylabel(r'$\frac{d}{dx} f(x)$', fontsize=15)
ax.tick_params(axis='both', which='major', labelsize=10)
ax.grid('minor')
plt.show()
plt.style.use(['science', 'notebook', 'grid'])
fig, ax = plt.subplots(1, 1, figsize=(8,3))
ax.plot(x, y, 'o--', color='r', lw=1, ms=5)
ax.text(0.1, 0.1, 'text here', transform=ax.transAxes)
ax.set_xlabel('Time(s)')
ax.set_ylabel(r'$\frac{d}{dx} f(x)$', fontsize=15)
ax.tick_params(axis='both', which='major', labelsize=10)
ax.grid('major')
plt.show()
plt.style.use(['science', 'notebook', 'grid'])
fig, ax = plt.subplots(1, 1, figsize=(8,3))
ax.plot(x, y, 'o--', color='r', lw=1, ms=5)
ax.text(0.1, 0.1, 'text here', transform=ax.transAxes)
ax.set_xlabel('Time(s)')
ax.set_ylabel(r'$\frac{d}{dx} f(x)$', fontsize=15)
ax.tick_params(axis='both', which='minor', labelsize=10)
ax.grid('minor')
plt.show()
plt.style.use(['science', 'notebook', 'grid'])
fig, ax = plt.subplots(1, 1, figsize=(8,3))
ax.plot(x, y, 'o--', color='r', lw=1, ms=5)
ax.text(0.1, 0.1, 'text here', transform=ax.transAxes)
ax.set_xlabel('Time(s)')
ax.set_ylabel(r'$\frac{d}{dx} f(x)$', fontsize=15)
ax.tick_params(axis='both', which='minor', labelsize=10)
ax.grid('major')
plt.show()
Creating the following plot
res_a1 = 0.2*np.random.randn(1000)+0.4
res_b1 = 0.25*np.random.randn(1000)+0.4
res_a2 = 0.21*np.random.randn(1000)+0.3
res_b2 = 0.22*np.random.randn(1000)+0.3
res_a1
array([ 0.53706106, 0.09092345, 0.44297261, 0.3971587 , 0.58147618,
0.38043837, 0.42944279, 0.12042916, 0.10805351, 0.49859688,
0.58734148, 0.44958496, 0.74113972, 0.06017804, 0.13065208,
0.25616705, 0.51275934, 0.69715773, 0.78283581, 0.20306139,
0.33423718, 0.42265135, 0.41676025, 0.46942775, 0.1788309 ,
0.59455238, 0.46837013, 0.25047649, 0.19254628, 0.58279778,
0.34557362, 0.23345237, 0.19861986, 0.37696096, 0.63422154,
0.46752813, 0.35311792, 0.50162699, -0.14111933, 0.29561268,
0.66184121, 0.08311108, 0.21762748, 0.47997024, 0.62247507,
0.48378706, 0.33594168, 0.67470012, 0.15345648, 0.00879505,
0.70535675, 0.20206325, 0.43377585, 0.21950043, 0.44270032,
0.54169002, 0.18219366, 0.2593598 , 0.33990318, 0.12097314,
0.4707033 , 0.169852 , 0.62700475, -0.00455813, 0.16735165,
0.60589462, 0.3395431 , 0.57982169, 0.32161073, 0.15368509,
0.4303693 , 0.36866465, 1.04320698, 0.26741686, 0.63945706,
0.47290826, 0.48122212, 0.29606462, 0.19516069, 0.60116129,
0.32778591, 0.55461595, -0.12275283, 0.25205812, 0.27066157,
0.35113571, 0.38357275, 0.22308244, -0.02424786, 0.70295091,
0.1727155 , 0.46210908, 0.80327247, 0.27636851, 0.36993629,
0.38434198, 0.62217006, 0.41801278, 0.347237 , 0.38562118,
0.35932109, 0.62959074, 0.78167382, 0.23371607, 0.50416459,
0.39632637, 0.64299007, 0.16679553, 0.30446827, 0.28450435,
0.25371798, 0.49435342, 0.44325518, 0.1355493 , 0.25895727,
0.31919145, 0.32355819, 0.11051556, 0.53446364, 0.48028967,
0.12606133, 0.63794884, 0.86346221, 0.3060493 , 0.69867298,
0.81598633, 0.67552313, 0.28269139, 0.4800447 , 0.3901144 ,
0.41245542, 0.23122817, 0.37996316, 0.64459813, 0.21971478,
0.37434515, 0.9123973 , 0.10163482, 0.44053124, 0.24207608,
0.3045325 , 0.45188054, -0.12828223, 0.57734556, 0.44561133,
0.36747936, 0.3644816 , 0.12610941, 0.21571934, 0.47223896,
0.37525564, 0.64853901, 0.61907674, 0.27881105, 0.59091557,
0.24973802, 0.51033384, 0.29042087, 0.30502273, 0.28423302,
0.16752387, 0.53965133, 0.55622157, 0.49832931, 0.48354617,
0.59132802, 0.51522835, 0.39463862, 0.31309059, 0.24020676,
0.60331474, 0.59451954, 0.54610528, 0.75079076, 0.97464365,
0.56245551, 0.47951529, 0.31136982, 0.34936368, 0.45017654,
0.07337879, 0.52353277, 0.44125774, 0.33514513, 0.61886712,
0.89046076, 0.76005863, 0.69808606, 0.29352252, 0.57121157,
0.21759234, 0.51633736, 0.42173877, 0.71756686, 0.18744601,
0.51798308, 0.22617763, 0.43748957, 0.3750329 , 0.23928971,
0.40522179, 0.6555432 , 0.45354627, 0.17136074, 0.35896685,
0.79347806, 0.38110182, 0.19066957, 0.40642546, 0.23597648,
0.34103748, 0.35439248, 0.36569009, 0.32467558, 0.69850378,
0.26783702, 0.31476667, 0.21606791, 0.31595746, 0.51814625,
0.21889941, 0.26384637, 0.29222135, 0.41117872, 0.32209812,
0.38389296, 0.25172852, 0.73826154, 0.4393454 , 0.43661754,
0.40673486, 0.23085188, 0.50108468, 0.38838532, 0.50422726,
0.70296556, 0.11898721, 0.56952127, 0.70900784, 0.79096198,
0.31952477, 0.74648007, 0.81802361, 0.21558634, 0.40573148,
0.64495574, 0.24917173, 0.54280916, 0.79093196, 0.1897866 ,
0.25119304, 0.13646469, 0.70581046, 0.23971912, 0.47413577,
0.43045974, 0.14984479, 0.32130526, 0.30500973, 0.5950111 ,
0.49669649, 0.49055595, 0.15817314, 0.7642534 , 0.65838364,
0.36127436, 0.41264183, 0.52592281, 0.54901071, 0.60845023,
0.3265467 , 0.18018592, 0.26612474, 0.48775529, 0.25154653,
0.10837653, 0.46975273, 0.02213782, 0.36440435, 0.4415768 ,
0.5115908 , 0.72165038, -0.03064654, 0.40869872, 0.82036483,
0.06094523, 0.6907146 , 0.54539563, 0.49951625, 0.3066197 ,
0.49270166, 0.08583813, 0.64541769, 0.40926793, 0.1271723 ,
0.71702155, 0.31268347, 0.36418443, 0.45164501, 0.45915833,
0.40693911, 0.36453735, 0.43537192, 0.63054625, 0.48888852,
0.31803704, 0.55611469, 0.16623417, 0.32941849, 0.27432522,
0.2415684 , 0.29549426, 0.61555108, 0.19290471, 0.16562977,
0.40870775, 0.20061046, 0.50738513, 0.17709507, 0.30527158,
0.41540161, 0.20185262, 0.71233194, 0.32973541, 0.54721805,
0.41464807, 0.42978664, 0.51979717, 0.38874083, 0.39511642,
0.25114755, 0.24210138, 0.4211319 , 0.4668018 , 0.48033483,
0.71445456, 0.42744067, 0.2301105 , 0.29496634, 0.03606382,
0.20343229, 0.57189349, 0.41305289, 0.43572621, 0.47182038,
0.53085083, 0.51259647, 0.67896971, 0.35879025, 0.48566729,
0.20926115, 0.41998676, 0.32451667, 0.40462824, 0.68549266,
0.44272109, 0.2008751 , 0.54738573, 0.4099816 , 0.58392715,
0.56676407, 0.53115491, 0.70296636, 0.63172447, 0.24096615,
0.3104594 , 0.4465337 , 0.67213235, 0.36523163, 0.58601136,
0.26471279, 0.2735722 , 0.27017111, 0.61565459, 0.22573843,
0.3149361 , 0.03139641, 0.83695086, 0.29492184, 0.33125782,
0.50831843, 0.37649229, 0.99364035, 0.31878133, 0.45280027,
0.27422573, 0.5629657 , 0.1519791 , 0.20159338, 0.57309421,
0.62303219, 0.50562353, 0.08406881, 0.39528841, 0.53762722,
0.11395186, 0.44074834, 0.63989816, 0.43956433, 0.71526115,
0.39573902, 0.41782816, 0.59478289, 0.2913705 , 0.54665639,
0.50059882, 0.20746656, 0.21633617, 0.29328564, 0.15619529,
0.41335674, 0.76328746, 0.50240231, 0.43861013, 0.35273726,
0.00755818, 0.47220177, 0.6597174 , 0.31175062, 0.48439515,
0.62300631, 0.59800583, 0.19636319, 0.32261234, 0.44392486,
0.33283424, 0.25883772, 0.35478153, 0.62236345, 0.18976177,
0.31518237, 0.52404478, 0.37406333, 0.59333411, 0.67787243,
0.78380865, 0.69137397, 0.76119752, 0.27879103, 0.2616703 ,
0.54283826, 0.06344377, 0.59820705, 0.44563865, 0.53046987,
0.43771017, 0.56445339, 0.38725428, 0.24851678, 0.75862287,
0.31913373, 0.31327049, 0.51263807, 0.2121433 , 0.19122743,
0.68582598, 0.64236385, 0.25424705, -0.06948703, 0.23693527,
0.35675618, 0.40305212, 0.44858131, 0.1085405 , 0.0485327 ,
0.7013539 , 0.44438484, 0.45893113, 0.23017667, 0.41204425,
0.35822463, 0.15862452, 1.04877901, 0.43733498, 0.34434906,
0.28852837, 0.60736446, 0.24949967, 0.05253564, 0.60547227,
0.27568976, 0.05990747, 0.38493553, 0.72633565, 0.06801505,
0.42688689, 0.51783805, 0.27514716, 0.6375917 , 0.85587494,
0.64038931, 0.39898869, 0.61102383, 0.29922253, 0.36146005,
0.35745988, 0.56994965, 0.63562327, 0.40021203, 0.41897492,
0.29154193, 0.15184405, 0.32508217, 0.69622386, 0.55762874,
0.32133247, 0.39654576, 0.30668072, 0.05539188, 0.34208426,
0.05035552, 0.52047232, 0.33394013, 0.40866204, 0.24699611,
0.15455289, 0.20173499, 0.39435303, 0.25680014, 0.23222286,
0.76314552, 0.25000879, 0.28669324, 0.03448195, 0.32115141,
0.41993736, -0.01269274, 0.50046868, 0.31618087, 0.76832951,
0.09038824, 0.3623926 , 0.84803844, 0.44151117, 0.3309744 ,
0.1941798 , 0.35586646, 0.52895421, 0.10091044, 0.7192503 ,
0.61105438, 0.19953192, 0.37448455, 0.46602826, 0.44244401,
0.14911991, 0.23518901, 0.31831118, -0.02492618, 0.04750118,
0.19797959, 0.2937718 , 0.79316289, 0.16679284, 0.45187957,
0.34714305, 0.60169608, 0.49665535, 0.13514808, 0.31002687,
0.51396632, 0.29700791, 0.57258524, 0.17680513, 0.20276026,
0.36096625, 0.70704322, 0.3882481 , 0.53745731, 0.16552276,
0.75884996, 0.25771637, 0.00329108, 0.43462086, 0.17449285,
0.54416731, 0.18283135, 0.54690997, 0.32812587, 0.24015561,
0.37558362, 0.34586164, 0.69393136, 0.52983292, 0.58802719,
0.62542637, 0.20633755, 0.19011204, 0.3556355 , 0.10200103,
0.31726844, 0.61310512, 0.39079466, 0.42853281, 0.29370677,
0.48836401, 0.38260905, 0.18372893, 0.25068912, 0.46113199,
0.31695097, 0.73754567, 0.50122901, 0.63293453, 0.44584116,
0.22062183, 0.58560865, 0.19508677, 0.35622414, 0.27786473,
0.22699135, 0.49945855, 0.65765553, 0.54775442, 0.12442254,
0.21241512, 0.47999275, 0.42232787, 0.40215866, 0.36564083,
0.01788311, 0.48767592, 0.4872378 , 0.35980827, 0.28596657,
0.4509687 , 0.29589767, 0.67617978, 0.23324332, 0.28772275,
0.21641912, 0.59559132, 0.50227093, 0.57160491, 0.12528199,
0.68997867, 0.2865068 , 0.4164978 , 0.42767826, 0.35512801,
0.36390191, 0.41785117, 0.52702263, 0.3080539 , 0.5263498 ,
0.53573064, 0.70537264, 0.22800016, 0.40695776, 0.62088481,
0.37428016, 0.41068326, 0.13443902, 0.23906211, 0.37833239,
0.21670347, 0.66327668, 0.50144957, 0.10437929, 0.41401852,
0.55657579, 0.35697018, 0.21544493, 0.61017347, 0.44236555,
0.62618236, 0.52904046, 0.55556784, 0.47904202, 0.01617444,
0.52150015, 0.08683578, 0.5826919 , 0.32493198, 0.54994769,
0.41606887, 0.17485845, 0.40639353, 0.35558444, 0.50066452,
0.15089541, 0.59786823, 0.57719568, -0.0520356 , 0.47328334,
0.38903309, 0.27040992, 0.52279614, 0.55772948, 0.42206545,
0.28216158, 0.27611526, 0.22157539, 0.71226067, 0.28612107,
0.72959143, 0.47327523, 0.63675215, 0.69937582, 0.72199167,
0.21581056, 0.51950946, 0.58474083, 0.35445355, 0.47990627,
0.25248002, 0.41070003, 0.15679805, 0.65289619, 0.25966885,
0.78961118, 0.53296325, 0.39637903, 0.45127791, 0.01291762,
0.16834696, 0.42241846, 0.1865833 , 0.26101549, 0.51575762,
0.43864767, 0.39945639, 0.62178326, 0.48183734, 0.34869202,
0.50230143, 0.53656778, 0.37098257, 0.40097434, -0.00238873,
0.12068945, 0.42077725, 0.42070854, 0.3086665 , 0.70570599,
0.70529542, 0.57381846, 0.30537764, 0.49306069, 0.27211591,
0.10454611, 0.42661194, 0.3172947 , 0.19384414, 0.50056088,
0.60220131, 0.74610239, 0.57092488, 0.34759184, 0.33447558,
0.3327017 , 0.15434263, 0.44617971, 0.06328989, 0.18858527,
0.34168822, 0.26251875, 0.39052853, 0.48274465, 0.46618939,
0.36364427, 0.52183114, 0.21668654, 0.75012335, 0.45488271,
-0.03708733, 0.71411961, 0.16641778, 0.09623113, 0.31844729,
0.22691516, 0.20903377, 0.2880195 , 0.23519612, 0.34110407,
0.32528228, 0.33336618, 0.5263205 , 0.53832761, 0.63380296,
0.29619873, 0.62291481, 0.08306306, 0.5602393 , 0.69400063,
0.51310035, 0.64007037, 0.2908748 , 0.46532484, 0.28017934,
0.15887301, 0.46007129, 0.59969441, 0.31944609, 0.14972578,
0.86848083, 1.01642221, 0.22781806, 0.56914399, 0.19341163,
0.03495728, 0.37780626, 0.43282426, 0.65546641, 0.01105678,
0.33634145, -0.06522817, 0.29078921, 0.12685667, 0.09418529,
0.32845855, 0.54836528, 0.28316277, 0.60630214, 0.31685782,
0.46951277, 0.31121956, 0.08412447, 0.81418917, 0.57557904,
0.25675403, 0.55048414, 0.62336164, 0.30742059, 0.29195192,
0.53820437, 0.70098784, 0.89314065, 0.38131319, 0.2122529 ,
0.24615024, 0.30683815, 0.67936619, 0.38393316, 0.50477405,
0.06045513, 0.57304504, 0.04599019, 0.36620769, 0.66001193,
0.6518558 , 0.31866347, 0.51058982, 0.59441024, 0.22415831,
0.00368503, 0.05683916, 0.67538678, 0.45622787, 0.33411598,
0.24920846, 0.1460187 , 0.47383282, 0.53777718, 0.71216099,
0.5968254 , 0.40780337, 0.78069369, 0.28365968, 0.30840939,
0.53492108, 0.33403532, 0.38337356, 0.32040221, 0.61210291,
0.17109873, 0.30375487, 0.81439533, 0.39029692, 0.28705937,
0.47095551, 0.40789496, 0.33391859, 0.60440121, 0.50176842,
0.29580303, 0.26009877, 0.22549962, 0.63412979, 0.37887241,
0.84948255, 0.24710319, 0.26711935, 0.15776808, 0.21022164,
-0.081536 , 0.33406272, 0.61634587, 0.32035635, 0.48767223,
0.48734256, 0.37613021, 0.34718424, 0.1378584 , 0.63801655,
0.12046489, 0.53453419, 0.19939647, 0.57589545, 0.19814196,
0.23627396, 0.5813684 , 0.58574669, 0.30709989, 0.31997441,
0.42211153, 0.65180428, 0.39285915, 0.67826672, 0.51894605,
0.49244356, 0.74020828, 0.47311913, 0.12340451, 0.74180547,
0.7332458 , 0.33136837, 0.49522722, 0.45922086, 0.13884125,
0.35016458, 0.52065434, 0.4657211 , 0.55021432, 0.02264143,
0.61543146, 0.45474847, 0.08776027, 0.475851 , 0.14452061,
0.35655663, 0.53077753, 0.35585434, 0.49911491, 0.41342734,
0.29128983, 0.32897911, 0.59315778, 0.12244428, 0.53926604,
0.34700098, 0.45860988, 0.12077627, 0.39265804, 0.49242012,
0.61122506, 0.38420468, 0.33508903, 0.2130077 , 0.18405961,
0.37196236, 0.95111188, 0.34807336, 0.46231081, 0.8164078 ,
0.35748156, 0.34129369, 0.28342419, 0.32054981, 0.30818 ,
0.4197477 , 0.3637979 , 0.55422332, -0.14762074, 0.2114099 ,
0.57801204, 0.15979879, 0.11380273, 0.35272662, 0.05685052,
0.32220455, 0.27739922, 0.79976711, 0.44587783, 0.68608816,
-0.18593972, 0.14854989, 0.61397232, 0.54105513, 0.27544158,
0.47196382, 0.15998342, 0.60573303, 0.37642765, 0.62778249,
0.4722535 , 0.28171367, 0.53846221, 0.60248715, 0.48928109,
0.57889994, 0.82867085, 0.33826874, 0.24412692, 0.77498555,
0.22786846, 0.14303555, 0.35484073, 0.39661093, 0.02476493])
plt.hist(res_a1, bins=100)
(array([ 1., 0., 0., 2., 1., 1., 0., 0., 1., 2., 1., 0., 2.,
2., 3., 5., 5., 5., 3., 9., 3., 5., 7., 8., 10., 9.,
8., 17., 14., 11., 16., 17., 22., 19., 16., 22., 17., 18., 27.,
20., 31., 26., 23., 28., 24., 21., 21., 20., 29., 21., 24., 20.,
16., 25., 20., 24., 15., 19., 21., 17., 11., 17., 14., 18., 18.,
15., 16., 9., 8., 7., 6., 15., 13., 6., 4., 7., 7., 2.,
4., 6., 1., 6., 2., 2., 2., 1., 0., 2., 1., 0., 0.,
0., 1., 1., 0., 1., 0., 1., 0., 2.]),
array([-1.85939717e-01, -1.73592530e-01, -1.61245343e-01, -1.48898155e-01,
-1.36550968e-01, -1.24203781e-01, -1.11856593e-01, -9.95094062e-02,
-8.71622189e-02, -7.48150315e-02, -6.24678442e-02, -5.01206569e-02,
-3.77734696e-02, -2.54262823e-02, -1.30790950e-02, -7.31907666e-04,
1.16152796e-02, 2.39624670e-02, 3.63096543e-02, 4.86568416e-02,
6.10040289e-02, 7.33512162e-02, 8.56984035e-02, 9.80455908e-02,
1.10392778e-01, 1.22739965e-01, 1.35087153e-01, 1.47434340e-01,
1.59781527e-01, 1.72128715e-01, 1.84475902e-01, 1.96823089e-01,
2.09170277e-01, 2.21517464e-01, 2.33864651e-01, 2.46211839e-01,
2.58559026e-01, 2.70906213e-01, 2.83253401e-01, 2.95600588e-01,
3.07947775e-01, 3.20294962e-01, 3.32642150e-01, 3.44989337e-01,
3.57336524e-01, 3.69683712e-01, 3.82030899e-01, 3.94378086e-01,
4.06725274e-01, 4.19072461e-01, 4.31419648e-01, 4.43766836e-01,
4.56114023e-01, 4.68461210e-01, 4.80808398e-01, 4.93155585e-01,
5.05502772e-01, 5.17849959e-01, 5.30197147e-01, 5.42544334e-01,
5.54891521e-01, 5.67238709e-01, 5.79585896e-01, 5.91933083e-01,
6.04280271e-01, 6.16627458e-01, 6.28974645e-01, 6.41321833e-01,
6.53669020e-01, 6.66016207e-01, 6.78363395e-01, 6.90710582e-01,
7.03057769e-01, 7.15404957e-01, 7.27752144e-01, 7.40099331e-01,
7.52446518e-01, 7.64793706e-01, 7.77140893e-01, 7.89488080e-01,
8.01835268e-01, 8.14182455e-01, 8.26529642e-01, 8.38876830e-01,
8.51224017e-01, 8.63571204e-01, 8.75918392e-01, 8.88265579e-01,
9.00612766e-01, 9.12959954e-01, 9.25307141e-01, 9.37654328e-01,
9.50001515e-01, 9.62348703e-01, 9.74695890e-01, 9.87043077e-01,
9.99390265e-01, 1.01173745e+00, 1.02408464e+00, 1.03643183e+00,
1.04877901e+00]),
<BarContainer object of 100 artists>)
plt.hist(res_a1, bins=100)
plt.hist(res_b1, bins=100)
plt.show()
Good habit to come up with complicated strings beforehand
textstr1 = '\n'.join((
r'$\sigma_a=%.4f$' % (np.std(res_a1)),
r'$\sigma_b=%.4f$' % (np.std(res_b1))))
textstr2 = '\n'.join((
r'$\sigma_a=%.4f$' % (np.std(res_a2)),
r'$\sigma_b=%.4f$' % (np.std(res_b2))))
textstr1
'$\\sigma_a=0.2005$\n$\\sigma_b=0.2491$'
fig, axes = plt.subplots(1, 2, figsize = (10, 3.5))
fig, axes = plt.subplots(1, 2, figsize = (10, 3.5))
ax = axes[0]
ax.hist(res_a1)
(array([ 8., 35., 92., 194., 244., 201., 133., 70., 17., 6.]),
array([-0.18593972, -0.06246784, 0.06100403, 0.1844759 , 0.30794778,
0.43141965, 0.55489152, 0.67836339, 0.80183527, 0.92530714,
1.04877901]),
<BarContainer object of 10 artists>)
fig, axes = plt.subplots(1, 2, figsize = (10, 3.5))
ax = axes[0]
ax.hist(res_a1)
plt.show()
fig, axes = plt.subplots(1, 2, figsize = (10, 3.5))
ax = axes[0]
ax.hist(res_a1, bins = 30, density = True, histtype='step')
plt.show()
fig, axes = plt.subplots(1, 2, figsize = (10, 3.5))
ax = axes[0]
ax.hist(res_a1, bins = 30, density = True, histtype='step')
ax.hist(res_b1, bins = 30, density = True, histtype='step')
plt.show()
fig, axes = plt.subplots(1, 2, figsize = (10, 3.5))
ax = axes[0]
ax.hist(res_a1, bins = 30, density = True, histtype='step', label = "a")
ax.hist(res_b1, bins = 30, density = True, histtype='step', label = "b")
ax.legend(loc="upper right")
plt.show()
fig, axes = plt.subplots(1, 2, figsize = (10, 3.5))
ax = axes[0]
ax.hist(res_a1, bins = 30, density = True, histtype='step', label = "a")
ax.hist(res_b1, bins = 30, density = True, histtype='step', label = "b")
ax.legend(loc="upper right")
ax.text(0.05, 0.81, textstr1, transform=ax.transAxes)
plt.show()
fig, axes = plt.subplots(1, 2, figsize = (10, 3.5))
ax = axes[0]
ax.hist(res_a1, bins = 30, density = True, histtype='step', label = "a")
ax.hist(res_b1, bins = 30, density = True, histtype='step', label = "b")
ax.legend(loc="upper right")
ax.text(0.05, 0.81, textstr1, transform=ax.transAxes, bbox=dict(facecolor="white", edgecolor="black"))
plt.show()
fig, axes = plt.subplots(1, 2, figsize = (10, 3.5))
ax = axes[0]
ax.hist(res_a1, bins = 30, density = True, histtype='step', label = "a")
ax.hist(res_b1, bins = 30, density = True, histtype='step', label = "b")
ax.legend(loc="upper right", fancybox=False, edgecolor="black")
ax.text(0.05, 0.81, textstr1, transform=ax.transAxes, bbox=dict(facecolor="white", edgecolor="black"))
plt.show()
fig, axes = plt.subplots(1, 2, figsize = (10, 3.5))
ax = axes[0]
ax.hist(res_a1, bins = 30, density = True, histtype='step', label = "a")
ax.hist(res_b1, bins = 30, density = True, histtype='step', label = "b")
ax.legend(loc="upper right", fancybox=False, edgecolor="black")
ax.text(0.05, 0.81, textstr1, transform=ax.transAxes, bbox=dict(facecolor="white", edgecolor="black"))
ax.set_ylabel("Density")
fig.text(0.5, -0.04, "$\Delta E(eV)$")
plt.show()
fig, axes = plt.subplots(1, 2, figsize = (10, 3.5))
ax = axes[0]
ax.hist(res_a1, bins = 30, density = True, histtype='step', label = "a")
ax.hist(res_b1, bins = 30, density = True, histtype='step', label = "b")
ax.legend(loc="upper right", fancybox=False, edgecolor="black")
ax.text(0.05, 0.81, textstr1, transform=ax.transAxes, bbox=dict(facecolor="white", edgecolor="black"))
ax.set_ylabel("Density")
fig.text(0.5, -0.04, "$\Delta E(eV)$", ha = "center")
plt.show()
fig, axes = plt.subplots(1, 2, figsize = (10, 3.5))
ax = axes[0]
ax.hist(res_a1, bins = 30, density = True, histtype='step', label = "a")
ax.hist(res_b1, bins = 30, density = True, histtype='step', label = "b")
ax.legend(loc="upper right", fancybox=False, edgecolor="black")
ax.text(0.05, 0.81, textstr1, transform=ax.transAxes, bbox=dict(facecolor="white", edgecolor="black"))
ax.set_ylabel("Density")
fig.text(0.5, -0.04, "$\Delta E(eV)$", ha = "center", fontsize = 20)
plt.show()
fig, axes = plt.subplots(1, 2, figsize = (10, 3.5))
ax = axes[0]
ax.hist(res_a1, bins = 30, density = True, histtype='step', label = "a")
ax.hist(res_b1, bins = 30, density = True, histtype='step', label = "b")
ax.legend(loc="upper right", fancybox=False, edgecolor="black")
ax.text(0.05, 0.81, textstr1, transform=ax.transAxes, bbox=dict(facecolor="white", edgecolor="black"))
ax.set_ylabel("Density")
fig.text(0.5, -0.04, "$\Delta E(eV)$", ha = "center", fontsize = 20)
ax = axes[0]
ax.hist(res_a2, bins = 30, density = True, histtype='step', label = "a")
ax.hist(res_b2, bins = 30, density = True, histtype='step', label = "b")
ax.legend(loc="upper right", fancybox=False, edgecolor="black")
ax.text(0.05, 0.81, textstr2, transform=ax.transAxes, bbox=dict(facecolor="white", edgecolor="black"))
ax.set_ylabel("Density")
fig.text(0.5, -0.04, "$\Delta E(eV)$", ha = "center", fontsize = 20)
plt.show()
fig, axes = plt.subplots(1, 2, figsize = (10, 3.5))
ax = axes[0]
ax.hist(res_a1, bins = 30, density = True, histtype='step', label = "a")
ax.hist(res_b1, bins = 30, density = True, histtype='step', label = "b")
ax.legend(loc="upper right", fancybox=False, edgecolor="black")
ax.text(0.05, 0.81, textstr1, transform=ax.transAxes, bbox=dict(facecolor="white", edgecolor="black"))
ax.set_ylabel("Density")
fig.text(0.5, -0.04, "$\Delta E(eV)$", ha = "center", fontsize = 20)
ax = axes[1]
ax.hist(res_a2, bins = 30, density = True, histtype='step', label = "a")
ax.hist(res_b2, bins = 30, density = True, histtype='step', label = "b")
ax.legend(loc="upper right", fancybox=False, edgecolor="black")
ax.text(0.05, 0.81, textstr2, transform=ax.transAxes, bbox=dict(facecolor="white", edgecolor="black"))
ax.set_ylabel("Density")
fig.text(0.5, -0.04, "$\Delta E(eV)$", ha = "center", fontsize = 20)
plt.show()
fig, axes = plt.subplots(1, 2, figsize = (10, 3.5))
ax = axes[0]
ax.hist(res_a1, bins = 30, density = True, histtype='step', label = "a", color = "blue")
ax.hist(res_b1, bins = 30, density = True, histtype='step', label = "b", color = "red")
ax.legend(loc="upper right", fancybox=False, edgecolor="black")
ax.text(0.05, 0.81, textstr1, transform=ax.transAxes, bbox=dict(facecolor="white", edgecolor="black"))
ax.set_ylabel("Density")
fig.text(0.5, -0.04, "$\Delta E(eV)$", ha = "center", fontsize = 20)
ax = axes[1]
ax.hist(res_a2, bins = 30, density = True, histtype='step', label = "a")
ax.hist(res_b2, bins = 30, density = True, histtype='step', label = "b")
ax.legend(loc="upper right", fancybox=False, edgecolor="black")
ax.text(0.05, 0.81, textstr2, transform=ax.transAxes, bbox=dict(facecolor="white", edgecolor="black"))
ax.set_ylabel("Density")
fig.text(0.5, -0.04, "$\Delta E(eV)$", ha = "center", fontsize = 20)
plt.show()
fig, axes = plt.subplots(1, 2, figsize = (10, 3.5))
ax = axes[0]
ax.hist(res_a1, bins = 30, density = True, histtype='step', label = "a", color = "blue")
ax.hist(res_b1, bins = 30, density = True, histtype='step', label = "b", color = "red")
ax.legend(loc="upper right", fancybox=False, edgecolor="black")
ax.text(0.05, 0.81, textstr1, transform=ax.transAxes, bbox=dict(facecolor="white", edgecolor="black"))
ax.set_ylabel("Density")
fig.text(0.5, -0.04, "$\Delta E(eV)$", ha = "center", fontsize = 20)
ax = axes[1]
ax.hist(res_a2, bins = 30, density = True, histtype='step', label = "a", color = "cyan")
ax.hist(res_b2, bins = 30, density = True, histtype='step', label = "b", color = "gold")
ax.legend(loc="upper right", fancybox=False, edgecolor="black")
ax.text(0.05, 0.81, textstr2, transform=ax.transAxes, bbox=dict(facecolor="white", edgecolor="black"))
fig.text(0.5, -0.04, "$\Delta E(eV)$", ha = "center", fontsize = 20)
plt.show()
fig, axes = plt.subplots(1, 2, figsize = (10, 3.5))
ax = axes[0]
ax.hist(res_a1, bins = 30, density = True, histtype='step', label = "a", color = "blue")
ax.hist(res_b1, bins = 30, density = True, histtype='step', label = "b", color = "red")
ax.legend(loc="upper right", fancybox=False, edgecolor="black")
ax.text(0.05, 0.81, textstr1, transform=ax.transAxes, bbox=dict(facecolor="white", edgecolor="black"))
ax.set_ylabel("Density")
fig.text(0.5, -0.04, "$\Delta E(eV)$", ha = "center", fontsize = 20)
ax.set_title("First Title")
ax = axes[1]
ax.hist(res_a2, bins = 30, density = True, histtype='step', label = "a", color = "cyan")
ax.hist(res_b2, bins = 30, density = True, histtype='step', label = "b", color = "gold")
ax.legend(loc="upper right", fancybox=False, edgecolor="black")
ax.text(0.05, 0.81, textstr2, transform=ax.transAxes, bbox=dict(facecolor="white", edgecolor="black"))
fig.text(0.5, -0.04, "$\Delta E(eV)$", ha = "center", fontsize = 20)
ax.set_title("Second Title", color="red")
plt.show()
Generate some data
plt.style.use(['default'])
_ = np.linspace(-1, 1, 100)
x, y = np.meshgrid(_,_)
z = x**2+x*y
z
array([[ 2.00000000e+00, 1.93980206e+00, 1.88042037e+00, ...,
-3.87715539e-02, -1.97938986e-02, 0.00000000e+00],
[ 1.97979798e+00, 1.92000816e+00, 1.86103459e+00, ...,
-1.93857770e-02, 1.11022302e-16, 2.02020202e-02],
[ 1.95959596e+00, 1.90021426e+00, 1.84164881e+00, ...,
2.22044605e-16, 1.97938986e-02, 4.04040404e-02],
...,
[ 4.04040404e-02, 1.97938986e-02, -2.22044605e-16, ...,
1.84164881e+00, 1.90021426e+00, 1.95959596e+00],
[ 2.02020202e-02, -1.11022302e-16, -1.93857770e-02, ...,
1.86103459e+00, 1.92000816e+00, 1.97979798e+00],
[ 0.00000000e+00, -1.97938986e-02, -3.87715539e-02, ...,
1.88042037e+00, 1.93980206e+00, 2.00000000e+00]])
plt.contourf(x,y,z)
<matplotlib.contour.QuadContourSet at 0x7fcad6d8be80>
plt.contourf(x,y,z, levels=30)
<matplotlib.contour.QuadContourSet at 0x7fcad7178c70>
plt.contourf(x,y,z, levels=30)
plt.colorbar()
<matplotlib.colorbar.Colorbar at 0x7fcad73e5d00>
plt.contourf(x,y,z, levels=30)
plt.colorbar(label = "Temperature($\degree$C)")
<matplotlib.colorbar.Colorbar at 0x7fcad763b5e0>
plt.contourf(x,y,z, levels=30, vmin = 0.7)
plt.colorbar(label = "Temperature($\degree$C)")
<matplotlib.colorbar.Colorbar at 0x7fcad7986bb0>
plt.contourf(x,y,z, levels=30, vmax = 1.68)
plt.colorbar(label = "Temperature($\degree$C)")
<matplotlib.colorbar.Colorbar at 0x7fcad7bd2e50>
plt.contourf(x,y,z, levels=30, vmax = 1.68, cmap = "plasma")
plt.colorbar(label = "Temperature($\degree$C)")
<matplotlib.colorbar.Colorbar at 0x7fcad7e3ae80>
plt.contourf(x,y,z, levels=30, vmax = 1.68, cmap = "plasma")
plt.colorbar(label = "Temperature($\degree$C)")
plt.xlabel('Horizontal Position(m)')
plt.ylabel('Vertical Position(m)')
Text(0, 0.5, 'Vertical Position(m)')
plt.contour(x,y,z)
<matplotlib.contour.QuadContourSet at 0x7fcad83847f0>
cs = plt.contour(x,y,z)
plt.clabel(cs, fontsize=8)
<a list of 14 text.Text objects>
cs = plt.contour(x,y,z, levels = 20)
plt.clabel(cs, fontsize=8)
<a list of 28 text.Text objects>
3D Surface Plot (Generally not preferred). However, they tend to work well in animations (we'll get to this later)
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
ax.plot_surface(x, y, z, cmap="coolwarm")
<mpl_toolkits.mplot3d.art3d.Poly3DCollection at 0x7fcad90dc6a0>
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
ax.plot_surface(x,y,z, cmap='coolwarm', linewidth=0)
ax.view_init(elev=10, azim=50)
import numpy as np
from mpl_toolkits import mplot3d
import matplotlib.pyplot as plt
plt.style.use('seaborn-poster')
fig = plt.figure(figsize = (10,10))
ax = plt.axes(projection='3d')
plt.show()
fig = plt.figure(figsize = (8,8))
ax = plt.axes(projection='3d')
ax.grid()
t = np.arange(0, 10*np.pi, np.pi/50)
x = np.sin(t)
y = np.cos(t)
ax.plot3D(x, y, t)
ax.set_title('3D Parametric Plot')
# Set axes label
ax.set_xlabel('x', labelpad=20)
ax.set_ylabel('y', labelpad=20)
ax.set_zlabel('t', labelpad=20)
plt.show()
from mpl_toolkits import mplot3d
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
# syntax for 3-D projection
ax = plt.axes(projection ='3d')
# defining all 3 axes
z = np.linspace(0, 1, 100)
x = z * np.sin(25 * z)
y = z * np.cos(25 * z)
# plotting
ax.plot3D(x, y, z, 'green')
ax.set_title('3D line plot geeks for geeks')
plt.show()
from mpl_toolkits import mplot3d
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
# syntax for 3-D projection
ax = plt.axes(projection ='3d')
# defining axes
z = np.linspace(0, 1, 100)
x = z * np.sin(25 * z)
y = z * np.cos(25 * z)
c = x + y
ax.scatter(x, y, z, c = c)
# syntax for plotting
ax.set_title('3d Scatter plot geeks for geeks')
plt.show()
x = np.random.random(50)
y = np.random.random(50)
z = np.random.random(50)
fig = plt.figure(figsize = (10,10))
ax = plt.axes(projection='3d')
ax.grid()
ax.scatter(x, y, z, c = 'r', s = 50)
ax.set_title('3D Scatter Plot')
# Set axes label
ax.set_xlabel('x', labelpad=20)
ax.set_ylabel('y', labelpad=20)
ax.set_zlabel('z', labelpad=20)
plt.show()
x = [1, 2, 3, 4]
y = [3, 4, 5]
X, Y = np.meshgrid(x, y)
print(X)
[[1 2 3 4] [1 2 3 4] [1 2 3 4]]
print(Y)
[[3 3 3 3] [4 4 4 4] [5 5 5 5]]
fig = plt.figure(figsize = (12,10))
ax = plt.axes(projection='3d')
x = np.arange(-5, 5.1, 0.2)
y = np.arange(-5, 5.1, 0.2)
X, Y = np.meshgrid(x, y)
Z = np.sin(X)*np.cos(Y)
surf = ax.plot_surface(X, Y, Z, cmap = plt.cm.cividis)
# Set axes label
ax.set_xlabel('x', labelpad=20)
ax.set_ylabel('y', labelpad=20)
ax.set_zlabel('z', labelpad=20)
fig.colorbar(surf, shrink=0.5, aspect=8)
plt.show()
fig = plt.figure(figsize=(12,6))
ax = fig.add_subplot(1, 2, 1, projection='3d')
ax.plot_wireframe(X,Y,Z)
ax.set_title('Wireframe plot')
ax = fig.add_subplot(1, 2, 2, projection='3d')
ax.plot_surface(X,Y,Z)
ax.set_title('Surface plot')
plt.tight_layout()
plt.show()
For plotting vector fields
plt.style.use(['science', 'notebook', 'grid'])
w = 3
_ = np.linspace(-3,3,100)
X, Y = np.meshgrid(_,_)
U = -1 - X**2 + Y
V = 1 + X - Y**2
speed = np.sqrt(U**2 + V**2)
fig, axes = plt.subplots(2,2,figsize=(5,5))
fig, axes = plt.subplots(2,2,figsize=(7,7))
fig, axes = plt.subplots(2,2,figsize=(6,6))
ax = axes[0][0]
ax.streamplot(X, Y, U, V)
<matplotlib.streamplot.StreamplotSet at 0x7fcaf488fdf0>
fig, axes = plt.subplots(2,2,figsize=(7,7))
ax = axes[0][0]
ax.streamplot(X, Y, U, V)
ax = axes[0][1]
ax.streamplot(X, Y, U, V, color=speed)
<matplotlib.streamplot.StreamplotSet at 0x7fcaf3613c10>
fig, axes = plt.subplots(2,2,figsize=(7,7))
ax = axes[0][0]
ax.streamplot(X, Y, U, V)
ax = axes[0][1]
ax.streamplot(X, Y, U, V, color=speed)
ax = axes[1][0]
lw = 5*speed / speed.max()
ax.streamplot(X, Y, U, V, color=speed, linewidth=lw)
<matplotlib.streamplot.StreamplotSet at 0x7fcae979aaf0>
fig, axes = plt.subplots(2,2,figsize=(7,7))
ax = axes[0][0]
ax.streamplot(X, Y, U, V)
ax = axes[0][1]
ax.streamplot(X, Y, U, V, color=speed)
ax = axes[1][0]
lw = 5*speed / speed.max()
ax.streamplot(X, Y, U, V, color=speed, linewidth=lw)
ax = axes[1][1]
# ax.streamplot(X, Y, U, V, color=speed, linewidth=2)
seed_points = np.array([[0,1], [1,0]])
ax.streamplot(X, Y, U, V, color=U, linewidth=2, cmap='autumn', start_points=seed_points)
plt.savefig('figs/test1.jpeg', dpi=100)
im = plt.imread('figs/flower.png')
im
array([[[0.2784314 , 0.49411765, 0.81960785, 1. ],
[0.2784314 , 0.49411765, 0.81960785, 1. ],
[0.2784314 , 0.49411765, 0.81960785, 1. ],
...,
[0.36862746, 0.49803922, 0.30980393, 1. ],
[0.37254903, 0.49803922, 0.30588236, 1. ],
[0.37254903, 0.49803922, 0.29803923, 1. ]],
[[0.2784314 , 0.49411765, 0.81960785, 1. ],
[0.2784314 , 0.49411765, 0.81960785, 1. ],
[0.2784314 , 0.49411765, 0.81960785, 1. ],
...,
[0.37254903, 0.5019608 , 0.2901961 , 1. ],
[0.37254903, 0.5019608 , 0.28627452, 1. ],
[0.37254903, 0.5019608 , 0.28235295, 1. ]],
[[0.2784314 , 0.49411765, 0.81960785, 1. ],
[0.2784314 , 0.49411765, 0.81960785, 1. ],
[0.2784314 , 0.49411765, 0.81960785, 1. ],
...,
[0.37254903, 0.5019608 , 0.27058825, 1. ],
[0.37254903, 0.5019608 , 0.27058825, 1. ],
[0.37254903, 0.5019608 , 0.27058825, 1. ]],
...,
[[0.48235294, 0.60784316, 0.34117648, 1. ],
[0.47843137, 0.6039216 , 0.3372549 , 1. ],
[0.47843137, 0.6039216 , 0.3372549 , 1. ],
...,
[0.41568628, 0.5294118 , 0.20784314, 1. ],
[0.42352942, 0.5411765 , 0.21568628, 1. ],
[0.4117647 , 0.5254902 , 0.2 , 1. ]],
[[0.48235294, 0.60784316, 0.34117648, 1. ],
[0.47843137, 0.6039216 , 0.3372549 , 1. ],
[0.4745098 , 0.6039216 , 0.3372549 , 1. ],
...,
[0.43529412, 0.54901963, 0.22745098, 1. ],
[0.4392157 , 0.5529412 , 0.22745098, 1. ],
[0.42352942, 0.5411765 , 0.21568628, 1. ]],
[[0.48235294, 0.60784316, 0.34117648, 1. ],
[0.4745098 , 0.6039216 , 0.3372549 , 1. ],
[0.4745098 , 0.6 , 0.33333334, 1. ],
...,
[0.4392157 , 0.5529412 , 0.23137255, 1. ],
[0.4392157 , 0.5529412 , 0.22745098, 1. ],
[0.42352942, 0.5411765 , 0.21568628, 1. ]]], dtype=float32)
plt.imshow(im)
<matplotlib.image.AxesImage at 0x7fcad9538fd0>
Animations require relating the time of your problem to the frame of the animation, then specifying the frames per second
def f(x,t):
return np.sin(x-3*t)
x = np.linspace(0, 10*np.pi, 1000)
plt.plot(x, f(x, 0))
[<matplotlib.lines.Line2D at 0x7fcada92c220>]
plt.plot(x, f(x, 0))
plt.plot(x, f(x, 0.1))
[<matplotlib.lines.Line2D at 0x7fcadae0b790>]
plt.plot(x, f(x, 0))
plt.plot(x, f(x, 0.1))
plt.plot(x, f(x, 0.2))
plt.plot(x, f(x, 1))
plt.plot(x, f(x, 1.2))
[<matplotlib.lines.Line2D at 0x7fcadb55e9d0>]
from matplotlib import animation
from matplotlib.animation import PillowWriter
fig, ax = plt.subplots(1,1, figsize=(8,4))
fig, ax = plt.subplots(1,1, figsize=(8,4))
ln1, = plt.plot([], [])
fig, ax = plt.subplots(1,1, figsize=(8,4))
ln1, = plt.plot([], [])
time_text = ax.text(0.65, 0.95, '', fontsize=15, bbox=dict(facecolor='white', edgecolor='black'),
transform=ax.transAxes)
fig, ax = plt.subplots(1,1, figsize=(8,4))
ln1, = plt.plot([], [])
time_text = ax.text(0.65, 0.95, '', fontsize=15, bbox=dict(facecolor='white', edgecolor='black'),
transform=ax.transAxes)
fig, ax = plt.subplots(1,1, figsize=(8,4))
ln1, = plt.plot([], [])
time_text = ax.text(0.65, 0.95, '', fontsize=15, bbox=dict(facecolor='white', edgecolor='black'),
transform=ax.transAxes)
ax.set_xlim(0,10*np.pi)
ax.set_ylim(-1.5, 1.5)
(-1.5, 1.5)
fig, ax = plt.subplots(1,1, figsize=(8,4))
ln1, = plt.plot([], [])
time_text = ax.text(0.65, 0.95, '', fontsize=15, bbox=dict(facecolor='white', edgecolor='black'),
transform=ax.transAxes)
ax.set_xlim(0,10*np.pi)
ax.set_ylim(-1.5, 1.5)
def animate(i):
ln1.set_data(x, f(x, 1/50*i))
time_text.set_text('t={:.2f}'.format(i/60))
fig, ax = plt.subplots(1,1, figsize=(8,4))
ln1, = plt.plot([], [])
time_text = ax.text(0.65, 0.95, '', fontsize=15, bbox=dict(facecolor='white', edgecolor='black'),
transform=ax.transAxes)
ax.set_xlim(0,10*np.pi)
ax.set_ylim(-1.5, 1.5)
def animate(i):
ln1.set_data(x, f(x, 1/50*i))
time_text.set_text('t={:.2f}'.format(i/50))
ani = animation.FuncAnimation(fig, animate, frames=240, interval=50)
fig, ax = plt.subplots(1,1, figsize=(8,4))
ln1, = plt.plot([], [])
time_text = ax.text(0.65, 0.95, '', fontsize=15, bbox=dict(facecolor='white', edgecolor='black'),
transform=ax.transAxes)
ax.set_xlim(0,10*np.pi)
ax.set_ylim(-1.5, 1.5)
def animate(i):
ln1.set_data(x, f(x, 1/50*i))
time_text.set_text('t={:.2f}'.format(i/50))
ani = animation.FuncAnimation(fig, animate, frames=240, interval=50)
ani.save('figs/ani.gif', writer='pillow', fps=50, dpi=100)
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/matplotlib/animation.py:973: UserWarning: Animation was deleted without rendering anything. This is most likely unintended. To prevent deletion, assign the Animation to a variable that exists for as long as you need the Animation. warnings.warn(
The animation function can be used in other ways too. One can create 3D rotating gifs of surfaces.
_ = np.linspace(-1, 1, 100)
x, y = np.meshgrid(_,_)
z = x**2+x*y
plt.style.use(["default"])
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
ax.plot_surface(x,y,z, cmap='coolwarm', linewidth=0)
ax.view_init(elev=10, azim=0)
def animate(i):
ax.view_init(elev=10, azim=3*i )
ani = animation.FuncAnimation(fig, animate, frames=140, interval=50)
ani.save('figs/ani2.gif', writer='pillow', fps=30, dpi=100)
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0, 10, 0.2)
y = np.sin(x)
fig, axes = plt.subplots(2,3, gridspec_kw = {'width_ratios':[3, 1, 2]})
axes[0, 0].plot(x,y)
axes[1, 1].plot(y,x)
plt.show()
The 'gridspec_kw' argument is simple. Notie that we pass in an array of length three; this is the number of columns in the plot grid. This allows us to determine the ratio of the width of the columns. The same thing can be accomplished with the rows.
x = np.arange(0, 10, 0.2)
y = np.cos(x)
fig, axes = plt.subplots(2,3, gridspec_kw = {'height_ratios':[2, 1]})
axes[0, 0].plot(x,y)
axes[1, 1].plot(y,x)
plt.show()
Sometimes we want might two small subplots on the top and one small one on the bottom. This can be accomplished simply as follows.
fig = plt.figure()
ax1 = plt.subplot(221)
ax2 = plt.subplot(223)
ax3 = plt.subplot(122)
plt.show()
The numerical arguments work as follows. The first two numbers 22 or 12 represent a 2x2 or 1x2 grid. The third number 1 or 3 or 2 represents the position in that grid that the plot should go.
Another way of accomplishing this is using the subplot2grid feature.
The first tuple breaks the figure apart into a 3x3 grid. The second tuple places the top left corner of the 'ax' in that location on the grid. The colspan and rowspan then stretch out the plot so that it covers more area of the grid.
fig = plt.figure(figsize=(8,5))
ax1 = plt.subplot2grid((3, 3), (0, 0))
ax2 = plt.subplot2grid((3, 3), (0, 1), colspan=2)
ax3 = plt.subplot2grid((3, 3), (1, 0), colspan=2, rowspan=2)
ax4 = plt.subplot2grid((3, 3), (1, 2), rowspan=2)
fig, (ax1, ax2) = plt.subplots(1, 2, subplot_kw=dict(projection='polar'))
ax1.plot(x, y)
ax2.plot(x, y ** 2)
plt.show()
x = np.linspace(0, 2 * np.pi, 400)
y = np.sin(x ** 2)
fig, (ax1, ax2) = plt.subplots(2)
fig.suptitle('Axes values are scaled individually by default')
ax1.plot(x, y)
ax2.plot(x + 1, -y)
[<matplotlib.lines.Line2D at 0x7fcad4e5b370>]
fig, (ax1, ax2) = plt.subplots(2, sharex=True)
fig.suptitle('Aligning x-axis using sharex')
ax1.plot(x, y)
ax2.plot(x + 1, -y)
[<matplotlib.lines.Line2D at 0x7fcad86ba580>]
fig, axs = plt.subplots(3, sharex=True, sharey=True)
fig.suptitle('Sharing both axes')
axs[0].plot(x, y ** 2)
axs[1].plot(x, 0.3 * y, 'o')
axs[2].plot(x, y, '+')
[<matplotlib.lines.Line2D at 0x7fcaf26c36a0>]
fig = plt.figure()
gs = fig.add_gridspec(3, hspace=0)
axs = gs.subplots(sharex=True, sharey=True)
fig.suptitle('Sharing both axes')
axs[0].plot(x, y ** 2)
axs[1].plot(x, 0.3 * y, 'o')
axs[2].plot(x, y, '+')
# Hide x labels and tick labels for all but bottom plot.
for ax in axs:
ax.label_outer()
fig = plt.figure()
gs = fig.add_gridspec(2, 2, hspace=0, wspace=0)
(ax1, ax2), (ax3, ax4) = gs.subplots(sharex='col', sharey='row')
fig.suptitle('Sharing x per column, y per row')
ax1.plot(x, y)
ax2.plot(x, y**2, 'tab:orange')
ax3.plot(x + 1, -y, 'tab:green')
ax4.plot(x + 2, -y**2, 'tab:red')
for ax in axs.flat:
ax.label_outer()
fig, axs = plt.subplots(2, 2)
axs[0, 0].plot(x, y)
axs[0, 0].set_title("main")
axs[1, 0].plot(x, y**2)
axs[1, 0].set_title("shares x with main")
axs[1, 0].sharex(axs[0, 0])
axs[0, 1].plot(x + 1, y + 1)
axs[0, 1].set_title("unrelated")
axs[1, 1].plot(x + 2, y + 2)
axs[1, 1].set_title("also unrelated")
fig.tight_layout()