!wget https://github.com/tendo-sms/python_beginner_2023/raw/main/files_5/files.zip . !unzip files.zip !mv files/* . import matplotlib.pyplot as plt import pandas as pd # CSVファイルをデータフレームに読み込む df = pd.read_csv("spectrum3.csv") # プログラムを作成してみましょう # Figureの作成 fig = plt.figure() # Axesの作成 ax = fig.subplots() # 折れ線グラフのプロット # ax.plot(df["Wavelength"], df["Intensity1"], label="Int1") # ax.plot(df["Wavelength"], df["Intensity2"], label="Int2") # ax.plot(df["Wavelength"], df["Intensity3"], label="Int3") # for文を使ってプロット for num in range(3): ax.plot(df["Wavelength"], df["Intensity"+str(num+1)], label="Int"+str(num+1)) # グラフのタイトルを設定 ax.set_title("Practice Graph") # 軸のラベルを設定 ax.set_xlabel("WL") ax.set_ylabel("Int") # 凡例を設定 ax.legend() # グラフの画面表示 plt.show() # グラフのクローズ plt.close(fig) import matplotlib.pyplot as plt import pandas as pd # CSVファイルをデータフレームに読み込む df1 = pd.read_csv("scatter.csv") df2 = pd.read_csv("hist.csv") # プログラムを作成してみましょう # Figureの作成 fig = plt.figure() # Axesの作成 ax = fig.subplots(1, 2) # 散布図のプロット ax[0].scatter(df1["Content"], df1["Hardness"]) ax[1].hist(df2["Particle size"], bins=10) # グラフのタイトルを設定 ax[0].set_title("Scatter") ax[1].set_title("Histgram") # 軸のラベルを設定 ax[0].set_xlabel("Content") ax[0].set_ylabel("Hardness") ax[1].set_xlabel("Particle size (nm)") ax[1].set_ylabel("Frequency") # グラフの画面表示 plt.show() # グラフのクローズ plt.close(fig)