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

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

繪制時(shí)間太近

繪制時(shí)間太近

米琪卡哇伊 2022-06-22 17:31:01
我的情節(jié)將日期時(shí)間過(guò)于緊密地捆綁在一起。我有以下代碼:import pandas as pdimport matplotlib.pyplot as pltimport matplotlib.dates as mdimport matplotlib.dates as mdatesdata = {"Date":['2019-2-25 14:24:04', '2019-2-25 14:29:02', '2019-2-20 17:02:14',                '2019-3-25 08:12:54', '2019-3-25 12:32:32'],        "Quiz":[1,2,2,3,4],        "Score":[10,3,7,4,9]}df = pd.DataFrame.from_dict(data)df.Date = pd.to_datetime(df.Date)   fig = plt.figure(figsize = (11,9))ax = fig.add_subplot(111)ax.set_xticks(df.Date)ax.xaxis.set_major_formatter(mdates.DateFormatter('%d/%m/%Y %H:%M'))ax.set_xlabel("Date")ax.set_ylabel("Score")ax.plot_date(df.Date, df.Score)fig.autofmt_xdate(rotation=45)plt.show()這是情節(jié):我想繪制我的數(shù)據(jù)的日期。但是,某些日期時(shí)間太靠近了,我無(wú)法找到一種方法將它們均勻地分開(kāi)。我怎樣才能做到這一點(diǎn)?
查看完整描述

1 回答

?
蕪湖不蕪

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

嘗試這個(gè):


import pandas as pd

import matplotlib.pyplot as plt

import matplotlib.dates as md

import matplotlib.dates as mdates

import datetime as dt


data = {"Date":['2019-2-25 14:24:04', '2019-2-25 14:29:02', '2019-2-20 17:02:14',

                '2019-3-25 08:12:54', '2019-3-25 12:32:32'],

        "Quiz":[1,2,2,3,4],

        "Score":[10,3,7,4,9]}


df = pd.DataFrame.from_dict(data)


xs = df.Date.values


fig, ax = plt.subplots(1)


ax.set_xlabel("Date")

ax.set_ylabel("Score")


ax.plot_date(xs, df.Score)


fig.autofmt_xdate(rotation=45)

plt.show()

主要區(qū)別是刪除格式化業(yè)務(wù)并設(shè)置 xs = df.Date.values,然后讓圖表自己處理格式化fig.autofmt_xdate(rotation=45)。


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

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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