Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reverse axis values when using plotly?

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

like image 894
Andrew Avatar asked Nov 16 '16 22:11

Andrew


People also ask

How do you change the y axis values in Plotly?

Go to 'Axes', then 'Tick Labels' and depending on the axis you want to change, select X, Y, or 'ALL'.

How do I change the Y axis scale in Python Plotly?

Scatter() function to make a scatter plot. The go. Figure() function takes in data as input where we set the mode as 'lines' using mode='lines'. We have used the magic underscore notation i.e layout_yaxis_range=[-8,8] to set the y-axis range from -8 to 8.


2 Answers

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

like image 149
Maximilian Peters Avatar answered Oct 02 '22 18:10

Maximilian Peters


In case someone reaches here looking for reversing axis for some subplots in python.

fig.update_yaxes(autorange="reversed", row, col)
like image 40
Jughead Avatar answered Oct 02 '22 19:10

Jughead