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

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等效项。或者,如果有更好的方法可以做到这一点,我愿意接受。

最佳答案

删除这样的刻度标签

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

可绘制图表的选项列表在这里:
Plotly R Reference

关于plotly - 删除绘图轴标签,但保留工具提示标签,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35469107/

10-12 16:34