[英]ggplot legend options will not be adopted in ggplotly in shiny
我用ggplot2創建了一個情節,並希望用plottly在我的Shiny App中發布它。 不幸的是,沒有采用傳說的位置。 此外,向圖例中的每個條目添加1,並且圖表的標題消失。
我的情節的一部分
plot = ggplot() +
geom_bar(data = pi_plot, aes(x = as.Date(Month), y = value, fill = Domain), position = "stack", stat = "identity") +
geom_line(data = pi_fc_ly_plot, aes(x = as.Date(Month), y = value, group = PI, colour = PI), size = 0.75) +
theme(legend.title = element_blank()) +
labs(title = "Traffic",
subtitle = "Visits",
y = "Pageviews",
x = "Month",
caption = "Source: Google Analytics") +
scale_x_date(labels = date_format("%B"),
date_breaks = "month",
expand = c(0, 0)) +
scale_y_continuous(legend.position = "bottom")
在應用程序中調用Plot
ggplotly(plot)
我前段時間做過類似的事。 我將我的傳奇位置指定為我的ggplotly函數調用的一部分,而不是我的ggplot函數調用。 您可以嘗試按如下方式修改代碼,看看它是否有效
plot = ggplot() +
geom_bar(data = pi_plot, aes(x = as.Date(Month), y = value, fill = Domain), position = "stack", stat = "identity") +
geom_line(data = pi_fc_ly_plot, aes(x = as.Date(Month), y = value, group = PI, colour = PI), size = 0.75) +
theme(legend.title = element_blank()) +
labs(title = "Traffic",
subtitle = "Visits",
y = "Pageviews",
x = "Month",
caption = "Source: Google Analytics") +
scale_x_date(labels = date_format("%B"),
date_breaks = "month",
expand = c(0, 0))
ggplotly(plot) %>% layout(legend = list(orientation = "h", y=-0.5))
我不知道你的標題問題的來源。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.