删除绘图轴标签但保留工具提示标签
remove plotly axis label but keep tooltip label
我有一个 table 类别标题很长,但我希望它们在悬停时显示。
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
我有一个 table 类别标题很长,但我希望它们在悬停时显示。
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