Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Add ggrepel support #2408

Open
emilianomm opened this issue Dec 10, 2024 · 1 comment
Open

[Feature Request] Add ggrepel support #2408

emilianomm opened this issue Dec 10, 2024 · 1 comment

Comments

@emilianomm
Copy link

Description

Currently plotly does no support labels created with ggrepel::geom_text_repel.

Feature requested

It is possible to make ggplotly compatible with labels generated with ggrepel package?

@MarjorieLeduc
Copy link

I also would like plotly to support ggrepel::geom_text_repel.
I prepare the following shiny that works with plotOutput but not with plotlyOutput :

library(shiny)
library(plotly)
library(ggplot2)
library(ggrepel)
library(bslib)

ui <- page_sidebar(
  title = "Hello Shiny!",
  sidebar = sidebar(
    selectizeInput(
      inputId = "Test",
      label = "Tests to show",
      choices = paste("Test",1:272),
      multiple = TRUE
    )
  ),
  plotlyOutput(outputId = "distPlot")
)

server <- function(input, output) {
  
output$distPlot <- renderPlotly({
    
  x<-faithful
  x$test<-paste("Test",1:272)
  
  ggplot(x,aes(x=eruptions,y=waiting))+
    geom_point()+
    geom_text_repel(data = x[match(input$Test,x$test),],
                    aes(label = test),
                    color="blue")
    
  })
  
}

shinyApp(ui = ui, server = server)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants