私は最近、非常に強力なインタラクティブなオンライン プロット システムである plotly に出会いました。そこで、matplot によって生成されたプロットを plotly に変換することを考えていました。時系列プロットを除いて、すべて正常に動作します。
ここに私のコードの簡単なバージョンがあります。
import pandas as pd
import matplotlib.pyplot as plt
import plotly.plotly as py
import plotly.tools as tls
tls.set_credentials_file(
username="edwinwang1988",
api_key="o8xw6s61dn")
import numpy as np
x = pd.date_range('1/1/2001',periods =72,freq='D') # genrate a date range
Series = pd.DataFrame(x,columns=['Date']) # generate a date range data frame
np.random.seed(0)
col = ['A','B','C','D'] #set col names for return series
s = pd.DataFrame(np.random.randn(72,4),columns=col) # generate random return series with col names as col
for i in range(len(col)):
s[col[i]] = s[col[i]].cumsum()
s['Date']=x # add date to dataframe s
s.plot(x='Date') # plot s and set date as x axis
これは正常に機能し、日付を x 軸として必要なプロットが得られます。しかし、図をプロットに変換しようとしたとき。
mpl_fig2= plt.gcf()
py.iplot_mpl(mpl_fig2,strip_styple = True,filename='test')
「min() arg is an empty sequence」のようなコード エラーが表示され、「year=1 は 1900 年より前です。datetime strftime() メソッドには year >= 1900 が必要です」というエラーが表示されることがあります。