R: ggplot and plotly axis margin won't change

后端 未结 3 1573
心在旅途
心在旅途 2020-12-10 12:47

I\'m having problems stopping the y-axis text from overlapping with the ticks using ggplotly around ggplot. How can I fix this? I\'ve tried the fol

3条回答
  •  自闭症患者
    2020-12-10 13:46

    Find an answer from Github that solved this problem elegantly.

    layout_ggplotly <- function(gg, x = -0.02, y = -0.08){
      # The 1 and 2 goes into the list that contains the options for the x and y axis labels respectively
      gg[['x']][['layout']][['annotations']][[1]][['y']] <- x
      gg[['x']][['layout']][['annotations']][[2]][['x']] <- y
      gg
    }
    gp %>% layout_ggplotly
    

提交回复
热议问题