![](/img/trans.png)
[英]curves messed up when converting ggplot2 to plotly using ggplotly
[英]How to change the legend position when transfer ggplot2 to plotly using `ggplotly`?
如下面的代碼,我從ggplot中構建了一個情節,並希望改變圖例的位置。
df <- data.frame(n=1:10, Var1 = rnorm(10), Var2 = rnorm(10))
data_long <- melt(df, id = "n")
a <- ggplot(data_long,
aes(x = n, y = value, colour = variable, group = variable)) +
geom_line()
ggplotly(a) %>% layout(legend = list(x = 0, y = 0), yaxis = list(title = ""))
但情節看起來像
部分傳奇標題仍位於圖表的頂部。
您可以使用legend.position參數:
a <- ggplot(data_long,
aes(x = n, y = value, colour = variable, group = variable)) +
geom_line() +
theme(legend.justification=c(0,0), legend.position=c(0,0))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.