我有以下代码
library(plotly)
A <- matrix(seq(1, 20), nrow = 4, ncol = 5)
p <- plot_ly(z = t(A), type = "heatmap", colorscale = "Greys")
p
是否有必要在y轴上的刻度之间切换以仅显示偶数(0、2、4)?
答案 0 :(得分:1)
您需要指定一些layout.yaxis.tick*
属性。您可以进一步了解here,以了解更多的自定义选项。
library(plotly)
A <- matrix(seq(1, 20), nrow = 4, ncol = 5)
p <- plot_ly(z = t(A), type = "heatmap", colorscale = "Greys")
p %>% layout(
yaxis = list(
tickmode = 'array',
tickvals = seq(0, 5, by = 2),
ticktext = seq(0, 5, by = 2)
)
)