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

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

僅使用第一個(gè)圖的刻度頻率在單個(gè)圖中混合來(lái)自熊貓數(shù)據(jù)框的線圖和散點(diǎn)圖

僅使用第一個(gè)圖的刻度頻率在單個(gè)圖中混合來(lái)自熊貓數(shù)據(jù)框的線圖和散點(diǎn)圖

至尊寶的傳說(shuō) 2023-04-25 15:47:00
我想比較數(shù)據(jù)框中的數(shù)據(jù),將一些數(shù)據(jù)繪制為線,將其他列繪制為散點(diǎn)圖。我的實(shí)際數(shù)據(jù)是模型輸出和觀察的組合,我希望觀察是散點(diǎn),模型是線。觀察值有很多 Nan 值(大多數(shù)時(shí)間步驟沒(méi)有觀察值)。這個(gè) MWE 重復(fù)了我遇到的問(wèn)題import numpy as npimport pandas as pdimport matplotlib.pyplot as pltbase = datetime.datetime.today()date_list = [base - datetime.timedelta(days=x) for x in range(40)]df = pd.DataFrame(data = {    "Time": date_list,    "Chocolate": np.random.rand(40),     "Strawberry": np.random.rand(40),     "Fake Chocolate": np.random.rand(40),     "Fake Strawberry": np.random.rand(40), })df.iloc[3,3] = np.nanax1 = df.plot(x = 'Time', y = ["Chocolate","Strawberry"])ax1 = df.plot(x = 'Time', y = ["Chocolate","Strawberry"])ax2 = df.plot.scatter(x = 'Time', y = ['Fake Chocolate'], marker = '^', ax = ax1)ax3 = df.plot.scatter(x = 'Time', y = ['Fake Strawberry'], marker = '*', ax = ax1, color = '#ff7f0e')我想要像第一個(gè)圖中那樣的 x 軸,所以采用線圖的樣式,你沒(méi)有每個(gè)日期都試圖在一個(gè)很小的空間中打印。我該怎么做呢?我正在使用ax1.set來(lái)設(shè)置 x 和 y 軸標(biāo)簽。如果我可以偷偷提出第二個(gè)問(wèn)題,為什么可以使用散點(diǎn)圖y = []而不是散點(diǎn)圖來(lái)做多條線?
查看完整描述

1 回答

?
飲歌長(zhǎng)嘯

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

只需添加plt.xticks(rotation=45)到腳本的末尾就可以了。


import numpy as np

import pandas as pd

import matplotlib.pyplot as plt

import datetime


base = datetime.datetime.today()

date_list = [base - datetime.timedelta(days=x) for x in range(40)]


df = pd.DataFrame(data = {

    "Time": date_list,

    "Chocolate": np.random.rand(40), 

    "Strawberry": np.random.rand(40), 

    "Fake Chocolate": np.random.rand(40), 

    "Fake Strawberry": np.random.rand(40), 

})

df.iloc[3,3] = np.nan


ax1 = df.plot(x = 'Time', y = ["Chocolate","Strawberry"])


ax1 = df.plot(x = 'Time', y = ["Chocolate","Strawberry"])

ax2 = df.plot.scatter(x = 'Time', y = ['Fake Chocolate'], marker = '^', ax = ax1)

ax3 = df.plot.scatter(x = 'Time', y = ['Fake Strawberry'], marker = '*', ax = ax1, color = '#ff7f0e')

plt.xticks(rotation=45);

http://img1.sycdn.imooc.com//644785a10001911203680267.jpg

http://img1.sycdn.imooc.com//644785ac00019bcf03830273.jpg

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

添加回答

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