![](/img/trans.png)
[英]How can I create a stacked bar graph for the WorldPhones dataset using plotly in R?
[英]how to put two variables from a dataset on a bar graph stacked in R
我嘗試在 R 中使用 plotly 來做到這一點
barstack<-plot_ly(Servicelevel, x=Servicelevel$Date, y=Servicelevel$Available,
color=Servicelevel$Series,type = "bar")
barstack <- barstack %>% add_trace(y = Servicelevel$Unavailable)
barstack<-barstack %>%
layout(title = "Percentage of Availability over time",
yaxis = list(title = 'Availability (%)',
tickformat = ".2%"),
xaxis=list(title='Date'), barmode = 'stack')
結果是這樣的:結果
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.