テキストデータを読んで折れ線グラフとヒストグラムを書いてみた
import pandas as pd import numpy as np import matplotlib.pyplot as plt df= pd.read_csv("OK.dat",engine="python",encoding="SHIFT-JIS") testItem = "ショートチェック" m = df[testItem].mean() std = df[testItem].std() # プロット領域(Figure, Axes)の初期化 fig = plt.figure(figsize=(12, 8)) ax1 = fig.add_subplot(211) ax2 = fig.add_subplot(212) print(m) print(std) ax1.hlines([m],0,df[testItem].count(),'red') ax1.hlines([m-3*std],0,df[testItem].count(),"red",linestyle='dashed') ax1.hlines([m+3*std],0,df[testItem].count(),"red",linestyle='dashed') ax1.plot(df[testItem]) ax2.hist(df[testItem]) ax1.set_title(testItem, fontname="MS Gothic") ax2.set_title(testItem, fontname="MS Gothic") plt.show()