plotly.py

  • Plotly Expressよりも低レベルなAPI

  • Plotlyと表記されることもある(ここでは plotly.js と分類するために plotly.py と表記)

import pandas as pd
import plotly.graph_objects as go
from plotly.subplots import make_subplots
def make_resample_df(df, rule):
    new_df = df.loc[:, "price"].resample(rule, label="right").ohlc()
    new_df.loc[:, "volume"] = df.loc[:, "size"].resample(rule, label="right").sum()
    new_df.loc[:, "instrument"] = df.loc[df.index[0], "instrument"]
    new_df.loc[:, "pct_change"] = new_df.loc[:, "close"].pct_change()
    new_df.reset_index(inplace=True)
    new_df.loc[:, "day_name"] = new_df.loc[:, "datetime"].dt.day_name()
    return new_df


btceur = pd.read_pickle("../data/binance_btc-eur.pkl")
etheur = pd.read_pickle("../data/binance_eth-eur.pkl")
resample_btceur = make_resample_df(btceur, "1H")
resample_etheur = make_resample_df(etheur, "1H")

figureオブジェクト

  • 描画領域全体(図)のオブジェクト

  • Matplotlibのfigureに近い

  • Figure クラスや make_subplots 関数などから生成

fig = go.Figure()
fig.show()