2017-07-19 9 views
1

私はpython、pandas、matplotlibを使って品質グラフを作るのに苦労しています。目標は、時間に基づいて素敵な折れ線グラフを作成し、ブール値に基づいて、TRUEを表示する何らかの種類のインジケータ(上に散らばっている)を持つことです。Matplotlibラインタイムシリーズ散布

今は起こっていますが、サークルが行を上書きするため、表示が非常に難しいです。時間枠も1年または5年に変更することができますので、ドットを調整する必要があります。また、伝説は表示されません。

def plot_stock(stock_prices_bollinger, ticker): 
plt.title(ticker) 
# y label 
plt.ylabel('stock price') 
# and a legend 
plt.legend(loc='upper right') 
plt.plot(stock_prices_bollinger['Price']) 
return plt.scatter(stock_prices_bollinger.index, stock_prices_bollinger['Price'], c=stock_prices_bollinger['breakout']) 

そして、次で関数を呼び出す:

ticker = 'MMM' 
from_date = '2011-01-01' 
to_date = '2016-10-01' 

Prices = stock_info(ticker, pd.to_datetime(from_date, format='%Y-%m-%d'), 
pd.to_datetime(to_date, format='%Y-%m-%d')) 
Prices_breakout = bollinger(Prices) 
plot_stock(Prices_breakout, ticker) 

enter image description here

+0

plt.plotとplt.scatterにはラベルがありませんので、凡例は表示されません。 – taras

答えて