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

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

寫(xiě)兩個(gè)或三個(gè) x 刻度標(biāo)簽,使用 matplotlib 顯示 UT 和 MLT

寫(xiě)兩個(gè)或三個(gè) x 刻度標(biāo)簽,使用 matplotlib 顯示 UT 和 MLT

慕的地6264312 2021-07-30 09:44:05
我正在嘗試制作這個(gè)圖,類(lèi)似于所附的示例圖。我還附上了示例數(shù)據(jù)。示例數(shù)據(jù)我想繪制一列(BLC 73.61、FCC 68.5、BSL 40.69)與時(shí)間的關(guān)系圖,它們位于數(shù)據(jù)框的索引中,并與日期時(shí)間 xticks 一起繪制,并希望顯示相應(yīng)的 MLT(磁性本地時(shí)間)值,即位于數(shù)據(jù)庫(kù)的第四列。這是我正在嘗試執(zhí)行的代碼:圖片展示了我想做的一個(gè)例子。x 刻度標(biāo)簽在一行中以日期時(shí)間格式顯示 uT 小時(shí)的值,在第二行或第三行中顯示 MLT 的對(duì)應(yīng)值# read the datadata = pd.read_csv('dados.csv', index_col=[0])#plotting fig = plt.figure(figsize=(10, 5)) #ax1 = fig.add_subplot(111)ax2 = ax1.twiny() # second x-axisax1.plot(data.index,data['BLC 73.61'])ax2.xaxis.set_ticks_position("bottom")ax2.xaxis.set_label_position("bottom")ax2.spines["bottom"].set_position(("axes", -0.2))ax2.spines['bottom'].set_color('none')majorLocator   = MultipleLocator(1)minorLocator   = MultipleLocator(1)ax1.xaxis.set_major_locator(majorLocator)ax1.xaxis.set_minor_locator(minorLocator)ax1.xaxis.set_major_locator(majorLocator)ax1.xaxis.set_minor_locator(minorLocator)ax1.xaxis.set_minor_formatter(dates.DateFormatter('%H:%M'))ax1.xaxis.set_minor_locator(mdates.MinuteLocator(interval=30))ax1.xaxis.set_major_formatter(dates.DateFormatter('%H:%M\n%b %d, %Y'))ax1.xaxis.set_major_locator(mdates.HourLocator(interval=30))ax2.set_xticklabels(data['MLT'].values)# ax2.xaxis.set_minor_formatter(dates.DateFormatter('%H:%M'))# ax2.xaxis.set_minor_locator(mdates.MinuteLocator(interval=30))# ax2.xaxis.set_major_formatter(dates.DateFormatter('%H:%M\n%b %d, %Y'))# ax2.xaxis.set_major_locator(mdates.HourLocator(interval=30))a=ax2.get_xticks().tolist()這是我得到的結(jié)果:
查看完整描述

1 回答

?
holdtom

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

我剛剛為此找到了一種解決方案。


我創(chuàng)建了一個(gè)函數(shù)來(lái)定義我想要的刻度并使用了 FuncFormatter 模塊。


def format_func(value, tick_number):


    hora = mdates.num2date(value)

    teste = mlt['BLC 73.61'][hora]

    return ('%d:%d \n %0.1f'  % (hora.hour, hora.minute,teste))


def format_func2(value, tick_number):

    # find the first value

    if tick_number == 0:

        return ('hh:mm     \n MLT     ')

    else:

        return (' ')

首先將時(shí)間戳值轉(zhuǎn)換為數(shù)字:


xx = [mdates.date2num(i) for i in ada[ini:end].index]

和情節(jié)


fig = plt.figure(figsize=(10, 5)) #

ax1 = fig.add_subplot(111)

ax1.plot(xx,ada['BLC 73.61'][ini:end])

# set the major locator ion the month values

ax1.xaxis.set_major_locator(mdates.MonthLocator(interval=5))

# use the format difeined in format_func2

ax1.xaxis.set_major_formatter(plt.FuncFormatter(format_func2))

ax1.xaxis.set_minor_locator(mdates.HourLocator(interval=2)) 

ax1.xaxis.set_minor_formatter(plt.FuncFormatter(format_func))


查看完整回答
反對(duì) 回復(fù) 2021-08-03
  • 1 回答
  • 0 關(guān)注
  • 150 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(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)