问题
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:
回答1:
You are probably looking for layout(xaxis = list(autorange = "reversed").
回答2:
At the moment reversed axis range in 3d is not supported in plotly. For this reason autorange = "reversed"
doesn't work.
回答3:
You can solve this by continuing to rotate the plot using turntable rotation. Originally, the axes are oriented with the largest values facing you. As you rotate, one by one they will become oriented the other way, then go back to where they started. This may be why autorange = "reversed"
doesn't work in 3d plots.
回答4:
You can rotate the plot by setting x=-x
, and/or y=-y
. You can then remove the minus sign in the plot by using tickvals = list(-x_ticks)
and ticktext = list(x_ticks)
in layout. Haven't found a way to remove the minus signal from the hovertext. But I guess I can't have it all =)
来源:https://stackoverflow.com/questions/40643288/how-to-reverse-axis-values-when-using-plotly