Search code examples
rplotlyggplotlybupar

Set dots size of dotted_chart() in combination with ggplotly()


Is there a way to reduce the size of the dots created with bupaR::dotted_chart() in combination with ggplotly()

library(bupaR)
library(eventdataR)
library(edeaR)
library(plotly)

ggplotly(dotted_chart(patients))

Solution

  • You could use plotly_build to modify the marker$size per line like this:

    library(bupaR)
    library(eventdataR)
    library(edeaR)
    library(plotly)
    
    p <- dotted_chart(patients)
    
    q <- plotly_build(p)
    q$x$data[[1]]$marker$size <- 1
    q$x$data[[2]]$marker$size <- 1
    q$x$data[[3]]$marker$size <- 1
    q$x$data[[4]]$marker$size <- 1
    q$x$data[[5]]$marker$size <- 1
    q$x$data[[6]]$marker$size <- 1
    q$x$data[[7]]$marker$size <- 1
    
    q
    

    Created on 2022-09-21 with reprex v2.0.2