user9787263
user9787263

Reputation:

Custom tick marks / labels appear on x & y axis in plotly surface plot?

I would like to control the tick marks for the surfaceplot

Using the standard volcano code here for a reproducible code. This is what I tried but it doesn't seem to be working.

p <- plot_ly(x = kd$x, y = kd$y, z = kd$z) %>% add_surface() %>%  layout(title = 'Example plot',xaxis = list(autotick = F, dtick = 10))  

I want the x-axis to be in an increment of 10 and y axis the digits need to be replaced by the words, but I am only looking for 3 ticks here like "Sixty" (instead of 60), "Eighty"(instead of 80) and "hundred" (instead of 100). I have no clue how to deal with the y axis.

In this answer too it says to try this, but it's not working for me. Control which tick marks / labels appear on x-axis in plotly?

In this, it mentions about adding a suffix but not replacing. Plotly in R: format axis - tick labels to percentage

Upvotes: 1

Views: 2741

Answers (1)

MLavoie
MLavoie

Reputation: 9836

For your first question (i.e., I want the x-axis to be in an increment of 10) hard to say since the x axis is from 1 to 4. But for your second question you could try this:

plot_ly(x = kd$x, y = kd$y, z = kd$z) %>% add_surface() %>% layout(scene = list(yaxis = list(
  tickmode = "array",
  nticks = 6,
  tickvals = c(60, 80, 100), 
ticktext = c("Sixty", "Eighty", "Hundred")
)))

enter image description here

Upvotes: 2

Related Questions