Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove plotly axis label but keep tooltip label

Tags:

plotly

I have a table where the category titles are quite long, but I'd like them to appear when hovering.

library(data.table)
library(plotly)
testTable <-
  structure(list(ACTUAL_LIFT = c(1.34, 1.21, 1.03, 2.39, 1.49, 
  1.32, 1.27, 1.32), PROMOTION_TITLE = c("longggggggggggggg title1", 
  "longggggggggggggg title2", "longggggggggggggg title3", "longggggggggggggg title4", 
  "longggggggggggggg title5", "longggggggggggggg title6", "longggggggggggggg title7", 
  "longggggggggggggg title8")), .Names = c("ACTUAL_LIFT", "PROMOTION_TITLE"
  ), class = c("data.table", "data.frame"), row.names = c(NA, -8L
  ))

a <- list(
    title = "Promo"
  )
  b <- list(
    title = "Lift"
  )
  p <- plot_ly(
    x = testTable[, PROMOTION_TITLE],
    y = (testTable[, ACTUAL_LIFT] - 1) * 100,
    name = "Lifts",
    type = "bar"
  ) %>% 
    layout(xaxis = a, yaxis = b)
 p

...just basically looking for a xlab = NULL equivalent here. Or if there's a better way to do this, I'm open to it.

like image 279
hedgedandlevered Avatar asked Aug 25 '26 16:08

hedgedandlevered


1 Answers

Remove the tick labels like this

p %>% layout(xaxis= list(showticklabels = FALSE))

The list of options for plotly charts is here: Plotly R Reference

like image 174
mal Avatar answered Sep 01 '26 03:09

mal