[英]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.