0

ggplotly prints some stuff from aes, namely "alpha" and "Continent", I have no idea why it goes like this.. please help to remove it!

Look at the upper right corner ->

My shiny app page

part of the code with 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"))
    })
  })
barbsan
  • 3,418
  • 11
  • 21
  • 28

1 Answers1

0

Continent is the legend title. To change it, you can do:

...... + scale_color_discrete(name = "MY_LEGEND_TITLE")

To get rid of the alpha, set it outside the aes:

geom_point(aes(text = paste("Country:", df1()[,1]), color = Continent), 
           size = 2, alpha = 0.85)
Stéphane Laurent
  • 75,186
  • 15
  • 119
  • 225