![](/img/trans.png)
[英]ggplotly tooltip - including label information that is not included in aes
[英]Aes in ggplotly
ggplotly 從 aes 打印一些東西,即“alpha”和“Continent”,我不知道為什么會這樣……請幫忙刪除它!
看右上角->
帶有 ggplot 的部分代碼:
server <- function(input, output) {
observe({
output$plot1 <- renderPlotly({
p <- ggplot(df1(), aes(x = df1()[,4], y = Happiness.Score))
p <- p + geom_point(size = 2, aes(text = paste("Country:", df1()[,1]), color = Continent, alpha = 0.85)) +
labs(title = "How happy is the country?", x = names(df1())[4], y = "Happiness Score") +
theme_light(base_size = 12) + ylim(2,8)
ggplotly(p, tooltip = c("text", "y"))
})
})
Continent
是傳說的標題。 要更改它,您可以執行以下操作:
...... + scale_color_discrete(name = "MY_LEGEND_TITLE")
要擺脫alpha
,請將其設置在aes
之外:
geom_point(aes(text = paste("Country:", df1()[,1]), color = Continent),
size = 2, alpha = 0.85)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.