各スパークラインの背景が変数(var4)に従って色付けされるように、スパークラインの小さな倍数グラフをプロットしようとしています。Rのggplotでこれを行うことができますが、Plotlyにうまく変換されません。
ggplot(data, aes(x=var1, y=var2, group=var3, text=var3)) +
geom_rect(data = data, aes(xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf, fill = var4), alpha = 0.4) +
geom_line() +
scale_fill_gradient2(low = "red", mid = "white", high = "red", midpoint = 0, space = "rgb", na.value = "grey50", guide = "colourbar") +
facet_wrap(~ var3, ncol = 44, scales = "fixed")
Plotlyでスパークラインを重ねて「ヒストグラム」を作成することを考えましたが、それもわかりません。
どんな考えでも大歓迎です。