用plotly在刻度之间更改步长

时间:2018-08-16 22:01:05

标签: r plotly heatmap

我有以下代码

library(plotly)
A <- matrix(seq(1, 20), nrow = 4, ncol = 5)
p <- plot_ly(z = t(A), type = "heatmap", colorscale = "Greys")
p 

enter image description here

是否有必要在y轴上的刻度之间切换以仅显示偶数(0、2、4)?

1 个答案:

答案 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)
  )
)

enter image description here