1
2つのグラフを結合して2番目のy軸を追加しようとしていますが、yaxis = "y2"をコードに追加するたびに、 。Rのプロットグラフの2番目のY軸
> MediaDate Spend Search_Visits Other_Visits MediaDate2
> 2016-04-01 $39654.36 19970 2899 Apr 2016
> 2016-05-01 $34446.28 14460 2658 May 2016
> 2016-06-01 $27402.36 12419 2608 Jun 2016
私の元のコードは次のとおりです。私は= "Y2" y軸を追加すると
p <- plot_ly(x= w$MediaDate2,y=w$Search_Visits,name = "Paid Search",
type = "bar")
p2 <- add_trace(p, x=w$MediaDate2, y=w$Other_Visits,name = "Other Traffic",
type = "bar")
spend_visits <- layout(p2, barmode = "stack")
spendvisits2 <- spend_visits %>% add_trace(data=w, x=MediaDate2, y=round(Spend,0), fill="tonexty", mode="lines",
text=w$MediaDate2, hoverinfo='name+y+text', name="Spend")
、唯一の面グラフは残る:
`spendvisits2 <- spend_visits %>% add_trace(data=w, x=MediaDate2, y=round(Spend,0), yxis="y2" fill="tonexty", mode="lines",
text=w$MediaDate2, hoverinfo='name+y+text', name="Spend")`
任意の提案は非常に参考になります。ありがとうございます
コードが完全に働いた、ありがとうございます!私は領域グラフを作成するために、コード[fill = "tozeroy"]を追加する必要があることを知っています。しかし、その領域の棒グラフを重ねる方法はありますか? –