Liky
Liky

Reputation: 1247

Change step between ticks with plotly

I have the following code

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

Is there anyway to change to steps between the ticks on the y-axis to display only the even numbers (0, 2, 4)?

Upvotes: 0

Views: 180

Answers (1)

Ameya
Ameya

Reputation: 1730

You need to specify some of the layout.yaxis.tick* attributes. You can read more about it here to see further customisation options.

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

Upvotes: 1

Related Questions