第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

Matplotlib - 以天和小時(shí)為單位繪制日期(x 軸)與值(y 軸)

Matplotlib - 以天和小時(shí)為單位繪制日期(x 軸)與值(y 軸)

拉風(fēng)的咖菲貓 2024-01-04 17:24:39
我有一個(gè)xlsx包含兩列的文件。第一個(gè)是時(shí)間戳 (DT-Index),如下所示 (18.01.2012 06:00:00),第二個(gè)包含正常值。我有 1 年的時(shí)間戳,每天 24 小時(shí),總共 8736 個(gè)值?,F(xiàn)在我想繪制這些數(shù)據(jù),如下圖所示。我面臨的問題是,有很多天,當(dāng)我嘗試像這樣繪制它們時(shí),我會(huì)出現(xiàn) 20 次甚至更多的星期一。如何實(shí)現(xiàn)如圖所示的解決方案?
查看完整描述

1 回答

?
嚕嚕噠

TA貢獻(xiàn)1784條經(jīng)驗(yàn) 獲得超7個(gè)贊

my_xticks1 = ['Montag','Dienstag','Mittwoch','Donnerstag','Freitag' , 'Samstag' , 'Sonntag' , 'aa']

my_major_xticks = ['00' , '00','00','00','00','00' , '00' , '00']

my_minor_xticks = [0 , 5 , 11 , 17 , 23 , 29 , 35 , 41 , 47 , 53 , 59 , 65 , 71 , 77 , 83 , 89 , 95 , 101 , 107 , 113 , 119 , 125 , 131 , 137 , 143 , 149 , 155 , 161 , 167]

my_minor_label = ['06' , '12' , '18' , '06' , '12' , '18' , '06' , '12' , '18' ,'06' , '12' , '18', '06' , '12' , '18' , '06' , '12' , '18' , '06' , '12' , '18']



fig, ax = plt.subplots()


ax.plot(list(dataB.keys()), list(dataB.values()), label="Dec-Feb" , color='#3074bb')

ax.plot(list(dataR.keys()), list(dataR.values()), label="Mar-Apr & Oct-Nov" , color='#bb3530')

ax.plot(list(dataP.keys()), list(dataP.values()), label="Dec-Feb" , color='#a630bb')

ax.plot(list(dataG.keys()), list(dataG.values()), label="Jun-Aug" , color='#30bb40')

ax.set_ylim(ymin=0)

ax.set_xlim(xmin=0)

ax.set_ylabel('W?rmelast / kW')

ax.set_title("Test")




#set the major xticks by its location and the location is presented by the length of the list

plt.xticks([0,23,47,71,95,119,143,167] , my_major_xticks)

# both for x and y axis


ax.tick_params('both', length=7, width=1, which='major')

plt.grid()


# control the minor locator and added a fixedlocator function to it

ax.xaxis.set_minor_locator(FixedLocator(my_minor_xticks))

# add the label to the minor locator

ax.xaxis.set_minor_formatter(FixedFormatter(my_minor_label))


ax.legend()


num = 11

for i, xpos in enumerate(ax.get_xticks()):

    if(i == 7):

        break;

    ax.text(num,-40, my_xticks1[i], 

            size = 10, ha = 'center')

    num = num + 24

我剛剛使用 xticks 、 set_minor_locator 和 ax.text 解決了它 我剛剛發(fā)布了上面的代碼


查看完整回答
反對(duì) 回復(fù) 2024-01-04
  • 1 回答
  • 0 關(guān)注
  • 141 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)