私は複数のデータ系列を持つ棒グラフを持っていますが、x軸値を%.2fの有意な値に設定したいのですが、すでに最初のグラフのset_majorフォーマッタ値は0にリセットされますが、値は2番目のグラフのようになります。棒グラフのx軸値を%.2fに設定
どうすればこの問題を解決できますか?
このような私のコードを見て:
import matplotlib.pyplot as plt
import pandas as pd
import matplotlib.ticker as mtick
# select the measurement location
MATH = "import/data/place"
SAVE = "save/location"
fig, axes = plt.subplots(figsize=(12,15),nrows=2, ncols=1) # size of the plots and the placing
fig.subplots_adjust(hspace=0.5) # set space between plots
DATA = pd.read_csv(MATH,delimiter=',',usecols = [2,3,4,5,6,7,8,9,10,11,12],names = ['set_t','set_rh',
'type','math','ref','LUFFT','VPL','VPR','VVL','VVR','PRO'], parse_dates=True)
# select the data
temp = DATA.loc[(DATA['type']=='T')&(DATA['math']=='dif')] # dif temperature data
rh = DATA.loc[((DATA['type']=='RH')&(DATA['math']=='dif'))] # dif relative humidity data
# plot temperature
fg = temp.plot.bar(x='set_t',y = ['LUFFT','VPL','VPR','VVL','VVR','PRO'],
color = ['b','firebrick','orange','forestgreen','darkturquoise','indigo'],
ax=axes[0])
fg.grid(True)
fg.set_ylabel('$ΔT$(°C)',fontsize = 12)
fg.set_xlabel('ref $T$ (°C)',fontsize = 12)
fg.set_title('Difference in T from reference at constant relative humidity 50%',fontsize = 15)
fg.yaxis.set_major_formatter(mtick.FormatStrFormatter('%.2f'))
fg.xaxis.set_major_formatter(mtick.FormatStrFormatter('%.2f'))
# plot relative humidity
df = rh.plot.bar(x='set_t',y = ['LUFFT','VPL','VPR','VVL','VVR','PRO'],
color = ['b','firebrick','orange','forestgreen','darkturquoise','indigo'],
ax=axes[1])
df.grid(True)
df.set_ylabel('$ΔU$(%)',fontsize = 12)
df.set_xlabel('ref $T$ (°C)',fontsize = 12)
df.set_title('Difference in U from reference at constant relative humidity 50%',fontsize = 15)
plt.tight_layout()
plt.savefig(SAVE + "_example.jpg")
plt.show()
私のデータのサンプル:
07:40:00,07:50:00,39.85716354999982,51.00504745588235、 T、dif ,, 0.14283645000018197、-0.07502069285698099、-0.15716354999978677,0.00202、-0.07111703837193772、-0.0620802166664447,
07:40:00,07:50:00,39.85716354999982,51.00504745588235、RH、DIF ,, - 0.40504745588239643,3.994952544117652,2.994952544117652,4.994952544117652、6.994952544117652、
08:40:00,08:50:00、 34.861160704969016,51.1297401832298、T、DIF ,, 0.22883929503095857,0.2509082605481865、-0.2575243413326831,0.24864321659958222,0.14092262836431502、-0.04441070496899613、
08:40:50:00,08 00,34.861160704969016,51.1297401832298、RH、DIF ,, - 0.32974018322978793 、3.8702598167702007,2.8702598167702007,4.870259816770201は、6.870259816770201、
質問を編集してCSVの値の小さなサンプルを含めると、問題を再現しやすくなります。 –
質問に追加しました – Sanne