pyplot

<Python, pandas> 日経平均を読み込む。

日経平均N225を読み込む。 pandas-datareaderを使う。 pandas-datareader — pandas-datareader 0.1 documentation まずはインストール。 % conda install pandas-datareader Fetching package metadata ......... Solving package specifications: .........…

<Python, matplotlib, pyplot> 線を描く

matplotlibで線lineを書く。 In [1]: import matplotlib.pyplot as plt In [2]: fig, ax = plt.subplots() ...: ax.hlines(y=1, xmin=0, xmax=1, colors='r', linewidths=5) ...: ax.axhline(y=1.5, xmin=0, xmax=1, color='g') ...: plt.hlines(y=[0,2,3], …

<Python, matplotlib, pyplot> Figureを作りすぎで怒られた場合。

fig, ax =plt.subplots()をループするスクリプトを作ったら、次のエラーで怒られた。 /hoge/python/lib/python3.4/site-packages/matplotlib/pyplot.py:424: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot in…

<Python, matplotlib, pyplot> 横軸、縦軸を調整する。

グラフの横軸、縦軸を調整する。 例えば、大きすぎる範囲なので、特定範囲を見せたい時とか、 pyplotの関数、xlim()とylim()を使う。 axの時は、set_xlim()らしい。 In [17]: import matplotlib.pyplot as plt ...: ...: x = range(1,20) ...: y = range(1,2…