How to reverse axis values when using plotly?

Andrew picture Andrew · Nov 16, 2016 · Viewed 11.2k times · Source

Here is the program I used:

library(plotly)

mydata = read.csv("data_to_plot.txt")
df = as.data.frame(mydata)

p <- df %>%
  group_by(X) %>%
  plot_ly(x = ~Y, y = ~X, z = ~Z, type = "scatter3d", mode = "lines")
p  

and below is an excerpt of "mydata":

df[1:12,]
X Y Z
1 1 0.2818017 0.0005993884
2 1 0.2832173 0.0007896421
3 1 0.2846330 0.0010293849
4 1 0.2860487 0.0013282462
5 1 0.2874643 0.0016969544

I would like to have the X values reversed on the X-axis, but can't find how to modify my program. Details of the plotly syntax are quite obscure to me. Could someone afford some help? Many thanks.

Data plotted: enter image description here

Answer

Maximilian Peters picture Maximilian Peters · Nov 16, 2016

You are probably looking for layout(xaxis = list(autorange = "reversed").