1
根據DataFrame中的某一列對pandas子圖進行陰影處理的最優雅方式是什麼?Matplotlib axvspan爲大熊貓着色基於列之一的DataFrame subplots
一個簡單的例子:
In [8]:
from random import *
import pandas as pd
randBinList = lambda n: [randint(0,1) for b in range(1,n+1)]
rng = pd.date_range('1/1/2011', periods=72, freq='H')
ts = pd.DataFrame({'Value1': randn(len(rng)),'Value2': randn(len(rng)),'OnOff': randBinList(len(rng))}, index=rng)
ts.plot(subplots=True)
結果在下面的情節:
理想情況下,我想的只是Value1
和Value2
用兩條曲線次要情節使用axvspan
其中被陰影On
(中的值爲1.0
)爲陰影且Off
不是陰影。