我想使用Gridspec配置子圖大小,如本問題所述。 Python/Matplotlib - Change the relative size of a subplot如何使用Gridspec和Pandas繪圖
這是怎麼回事,如果我想使用Pandas Dataframe的劇情功能?它有可能嗎?
我想使用Gridspec配置子圖大小,如本問題所述。 Python/Matplotlib - Change the relative size of a subplot如何使用Gridspec和Pandas繪圖
這是怎麼回事,如果我想使用Pandas Dataframe的劇情功能?它有可能嗎?
我不認爲你可以使用gridspec與熊貓的情節。 pandas plot module是matplotlib pyplot的包裝,並不一定實現所有功能。
如果檢查GitHub上的熊貓源和做gridspec你會發現,陰謀搜索沒有提供任何選項來配置gridspec
你可以這樣來做。
import pandas as pd
import pandas.io.data as web
import matplotlib.pyplot as plt
aapl = web.DataReader('AAPL', 'yahoo', '2014-01-01', '2015-05-31')
# 3 x 1 grid, position at (1st row, 1st col), take two rows
ax1 = plt.subplot2grid((3, 1), (0, 0), rowspan=2)
# plot something on this ax1
aapl['Adj Close'].plot(style='r-', ax=ax1)
# plot moving average again on this ax1
pd.ewma(aapl['Adj Close'], span=20).plot(style='k--', ax=ax1)
# get the other ax
ax2 = plt.subplot2grid((3, 1), (2, 0), rowspan=1)
ax2.bar(aapl.index, aapl.Volume)
你需要更具體。您可以通過傳入plot方法在任何Axes對象上使用'df.plot',例如'df.plot(...,ax = ax1)' –