このページの2つのバージョン間の差分を表示します。
|
2023年度:実験ゼミ:7_14 [2023/07/17 07:17] kataoka 作成 |
2023年度:実験ゼミ:7_14 [2023/07/17 07:20] (現在) kataoka |
||
|---|---|---|---|
| 行 1: | 行 1: | ||
| - | 7/14 の実験ゼミで用いたヒストグラムを書くコード | + | ====7/14 の実験ゼミで用いたヒストグラムを書くコード==== |
| + | |||
| + | <file py hist.py> | ||
| + | with open(' | ||
| + | lines = f.readlines() | ||
| + | |||
| + | # | ||
| + | import matplotlib.pyplot as plt | ||
| + | import numpy as np | ||
| + | |||
| + | # | ||
| + | c1,c2 =' | ||
| + | |||
| + | # | ||
| + | fig = plt.figure(figsize =(10,10), facecolor=' | ||
| + | |||
| + | # | ||
| + | ax1 = fig.add_subplot(2, | ||
| + | ax2 = fig.add_subplot(2, | ||
| + | |||
| + | # | ||
| + | ax1.plot([int (line) for line in lines[: | ||
| + | ax1.set_xlim([500, | ||
| + | |||
| + | N_POINTS = 1023 # sample数 | ||
| + | data = np.array([int (line) for line in lines]) # | ||
| + | length = len(data)// | ||
| + | data_res =data [: | ||
| + | |||
| + | # | ||
| + | def intg(d): | ||
| + | return (d[510:530] -d[: | ||
| + | ax2.hist([-intg(d) for d in data_res], | ||
| + | |||
| + | # | ||
| + | ax1.set_title(' | ||
| + | ax2.set_title(' | ||
| + | |||
| + | # | ||
| + | ax1.set_xlabel(" | ||
| + | ax1.set_ylabel(" | ||
| + | ax2.set_xlabel(" | ||
| + | ax2.set_ylabel(" | ||
| + | |||
| + | # | ||
| + | ax1.legend(loc =' | ||
| + | ax2.legend(loc =' | ||
| + | |||
| + | plt.show() | ||
| + | |||
| + | </ | ||