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

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

Pandas timeseries繪制設(shè)置x軸主要和次要刻度和標(biāo)簽

Pandas timeseries繪制設(shè)置x軸主要和次要刻度和標(biāo)簽

梵蒂岡之花 2019-08-01 14:25:36
Pandas timeseries繪制設(shè)置x軸主要和次要刻度和標(biāo)簽我希望能夠?yàn)閺腜andas時(shí)間序列對(duì)象繪制的時(shí)間序列圖設(shè)置主要和次要xticks及其標(biāo)簽。熊貓0.9“什么是新的”頁面說:“您可以使用to_pydatetime或?yàn)門imestamp類型注冊(cè)轉(zhuǎn)換器”但我無法弄清楚如何做到這一點(diǎn),以便我可以使用matplotlib ax.xaxis.set_major_locator和ax.xaxis.set_major_formatter(和次要)命令。如果我在不轉(zhuǎn)換熊貓時(shí)間的情況下使用它們,則x軸刻度和標(biāo)簽最終會(huì)出錯(cuò)。通過使用'xticks'參數(shù),我可以將主刻度傳遞給pandas.plot,然后設(shè)置主刻度標(biāo)簽。我無法弄清楚如何使用這種方法進(jìn)行次要滴答。(我可以在pandas.plot設(shè)置的默認(rèn)次要刻度上設(shè)置標(biāo)簽)這是我的測(cè)試代碼:import pandasprint 'pandas.__version__ is ', pandas.__version__print 'matplotlib.__version__ is ', matplotlib.__version__     dStart = datetime.datetime(2011,5,1) # 1 MaydEnd = datetime.datetime(2011,7,1) # 1 July    dateIndex = pandas.date_range(start=dStart, end=dEnd, freq='D')print "1 May to 1 July 2011", dateIndex       testSeries = pandas.Series(data=np.random.randn(len(dateIndex)),                            index=dateIndex)    ax = plt.figure(figsize=(7,4), dpi=300).add_subplot(111)testSeries.plot(ax=ax, style='v-', label='first line')    # using MatPlotLib date time locators and formatters doesn't work with new# pandas datetime indexax.xaxis.set_minor_locator(matplotlib.dates.WeekdayLocator(byweekday=(1),                                                            interval=1))ax.xaxis.set_minor_formatter(matplotlib.dates.DateFormatter('%d\n%a'))ax.xaxis.grid(True, which="minor")ax.xaxis.grid(False, which="major")ax.xaxis.set_major_formatter(matplotlib.dates.DateFormatter('\n\n\n%b%Y'))plt.show()    # set the major xticks and labels through pandasax2 = plt.figure(figsize=(7,4), dpi=300).add_subplot(111)xticks = pandas.date_range(start=dStart, end=dEnd, freq='W-Tue')print "xticks: ", xticks testSeries.plot(ax=ax2, style='-v', label='second line',
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 1990 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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