删除绘图轴标签但保留工具提示标签

时间:2016-02-17 22:33:06

标签: plotly

我有一个表格,类别标题很长,但我希望它们在悬停时出现。

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

...只是在这里基本上寻找xlab = NULL等价物。或者,如果有更好的方法,我可以接受它。

1 个答案:

答案 0 :(得分:9)

删除像这样的刻度标签

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

图表图表的选项列表如下: Plotly R Reference