r绘制代码中更改3D绘图摄像头
我目前正在尝试绘制不同数据的子图。
我需要代码来完全按照我想要的方式绘制不同的数字,而不必在之后修改它们。
问题,您可以在此处看到:
我在一个子图中与另一个图重叠的3D图有 需要手动将其(通过使用Zoom,Pan和the Plotly Display的转盘旋转)以我喜欢的方式,这种方式(大约):
如何通过代码自动化此过程?我已经阅读文档已经有一段时间了,找不到任何可能有效的工作。
非常感谢 !
您可以在下面找到我使用的代码:
dataresults1ab <- read.table("./Datas/dataresults1ab.txt")
dataresults1c <- read.table("./Datas/dataresults1c.txt")
dataresults1d <- read.table("./Datas/dataresults1d.txt")
Fig1a <- {plot_ly(dataresults1ab,x= ~time,y= ~N1,name = "Species 1", type = "scatter", mode = "lines") %>%
add_trace(y= ~N2, name = "Species 2", mode="lines") %>%
add_trace(y= ~N3, name = "Species 3", mode="lines")%>%
layout(title="Time course of the abundances of three species competing for three ressources",xaxis=list(title="Time (days)",range=c(0,200)),yaxis=list(title="Species abundances",range=c(0,50)))}
Fig1b<-{plot_ly(dataresults1ab, x = ~N1, y = ~N2, z = ~N3, type = "scatter3d", mode = "lines")%>%
layout(title="The corresponding limit cycle",
scene=list(xaxis=list(title="Species 1",range=c(0,50)),
yaxis=list(title="Species 2",range=c(0,50)),
zaxis=list(title="Species 3",range=c(0,50)),
camera=list(up=list(0,0.5,0.5))))}
Fig1c <- {plot_ly(dataresults1c,x= ~time,y= ~N1,name = "Species 1", type = "scatter", mode = "lines") %>%
add_trace(y= ~N2, name = "Species 2", mode="lines") %>%
add_trace(y= ~N3, name = "Species 3", mode="lines") %>%
add_trace(y= ~N4, name = "Species 4", mode="lines") %>%
add_trace(y= ~N5, name = "Species 5", mode="lines") %>%
add_trace(y= ~N6, name = "Species 6", mode="lines") %>%
layout(title="Small-amplitude oscilations of six species on three ressources",xaxis=list(title="Time (days)",range=c(0,15000)),yaxis=list(title="Species abundances",range=c(0,70)))}
Fig1d <- {plot_ly(dataresults1d,x= ~time,y= ~N1,name = "Species 1", type = "scatter", mode = "lines") %>%
add_trace(y= ~N2, name = "Species 2", mode="lines") %>%
add_trace(y= ~N3, name = "Species 3", mode="lines") %>%
add_trace(y= ~N4, name = "Species 4", mode="lines") %>%
add_trace(y= ~N5, name = "Species 5", mode="lines") %>%
add_trace(y= ~N6, name = "Species 6", mode="lines") %>%
add_trace(y= ~N7, name = "Species 7", mode="lines") %>%
add_trace(y= ~N8, name = "Species 8", mode="lines") %>%
add_trace(y= ~N9, name = "Species 9", mode="lines") %>%
layout(title="Large-amplitude oscilations of nine species on three ressources",xaxis=list(title="Time (days)",range=c(0,3000)),yaxis=list(title="Species abundances",range=c(0,40)))}
Fig1 <- {subplot(Fig1a,Fig1b,Fig1c,Fig1d,nrows=2,margin=0.1,titleY=T,titleX = T)%>%
layout(scene = list(domain = list(x = c(0.5,1), y = c(0.5,1))),
showlegend=F,
title="",
annotations = list(list(
x = 0,
y = 1,
text = "a)",
xref = "paper",
yref = "paper",
xanchor = "center",
yanchor = "bottom",
showarrow = F
),
list(
x = 0.6,
y = 1,
text = "b)",
xref = "paper",
yref = "paper",
xanchor = "center",
yanchor = "bottom",
showarrow = F
),
list(
x = 0,
y = 0.425,
text = "c)",
xref = "paper",
yref = "paper",
xanchor = "center",
yanchor = "bottom",
showarrow = F
),
list(
x = 0.6,
y = 0.425,
text = "d)",
xref = "paper",
yref = "paper",
xanchor = "center",
yanchor = "bottom",
showarrow = F
)))
}
您可以在此处找到我正在使用的数据: https://drop.chapril.org/download/3a18d06ab9d7efe3/#rhjx3zxvpmwwwwwyijaeq
I am currently trying to plot subplots of differents datas.
I need the code to plot the different figures exactly the way I want them without me having to modify them after.
I have a problem with a 3D plot overlapped with the other plot in a subplot, as you can see here :
I need to manualy resset it (by using the zoom, pan and turntable rotation of the plotly display) in order to have it the way I like, that way (approximately) :
How can I automatize this process through the code ? I have been reading documentation for a while and can't find anything that might do the job.
Thank you very much !
You can find the code I am using below :
dataresults1ab <- read.table("./Datas/dataresults1ab.txt")
dataresults1c <- read.table("./Datas/dataresults1c.txt")
dataresults1d <- read.table("./Datas/dataresults1d.txt")
Fig1a <- {plot_ly(dataresults1ab,x= ~time,y= ~N1,name = "Species 1", type = "scatter", mode = "lines") %>%
add_trace(y= ~N2, name = "Species 2", mode="lines") %>%
add_trace(y= ~N3, name = "Species 3", mode="lines")%>%
layout(title="Time course of the abundances of three species competing for three ressources",xaxis=list(title="Time (days)",range=c(0,200)),yaxis=list(title="Species abundances",range=c(0,50)))}
Fig1b<-{plot_ly(dataresults1ab, x = ~N1, y = ~N2, z = ~N3, type = "scatter3d", mode = "lines")%>%
layout(title="The corresponding limit cycle",
scene=list(xaxis=list(title="Species 1",range=c(0,50)),
yaxis=list(title="Species 2",range=c(0,50)),
zaxis=list(title="Species 3",range=c(0,50)),
camera=list(up=list(0,0.5,0.5))))}
Fig1c <- {plot_ly(dataresults1c,x= ~time,y= ~N1,name = "Species 1", type = "scatter", mode = "lines") %>%
add_trace(y= ~N2, name = "Species 2", mode="lines") %>%
add_trace(y= ~N3, name = "Species 3", mode="lines") %>%
add_trace(y= ~N4, name = "Species 4", mode="lines") %>%
add_trace(y= ~N5, name = "Species 5", mode="lines") %>%
add_trace(y= ~N6, name = "Species 6", mode="lines") %>%
layout(title="Small-amplitude oscilations of six species on three ressources",xaxis=list(title="Time (days)",range=c(0,15000)),yaxis=list(title="Species abundances",range=c(0,70)))}
Fig1d <- {plot_ly(dataresults1d,x= ~time,y= ~N1,name = "Species 1", type = "scatter", mode = "lines") %>%
add_trace(y= ~N2, name = "Species 2", mode="lines") %>%
add_trace(y= ~N3, name = "Species 3", mode="lines") %>%
add_trace(y= ~N4, name = "Species 4", mode="lines") %>%
add_trace(y= ~N5, name = "Species 5", mode="lines") %>%
add_trace(y= ~N6, name = "Species 6", mode="lines") %>%
add_trace(y= ~N7, name = "Species 7", mode="lines") %>%
add_trace(y= ~N8, name = "Species 8", mode="lines") %>%
add_trace(y= ~N9, name = "Species 9", mode="lines") %>%
layout(title="Large-amplitude oscilations of nine species on three ressources",xaxis=list(title="Time (days)",range=c(0,3000)),yaxis=list(title="Species abundances",range=c(0,40)))}
Fig1 <- {subplot(Fig1a,Fig1b,Fig1c,Fig1d,nrows=2,margin=0.1,titleY=T,titleX = T)%>%
layout(scene = list(domain = list(x = c(0.5,1), y = c(0.5,1))),
showlegend=F,
title="",
annotations = list(list(
x = 0,
y = 1,
text = "a)",
xref = "paper",
yref = "paper",
xanchor = "center",
yanchor = "bottom",
showarrow = F
),
list(
x = 0.6,
y = 1,
text = "b)",
xref = "paper",
yref = "paper",
xanchor = "center",
yanchor = "bottom",
showarrow = F
),
list(
x = 0,
y = 0.425,
text = "c)",
xref = "paper",
yref = "paper",
xanchor = "center",
yanchor = "bottom",
showarrow = F
),
list(
x = 0.6,
y = 0.425,
text = "d)",
xref = "paper",
yref = "paper",
xanchor = "center",
yanchor = "bottom",
showarrow = F
)))
}
You can find the data I am using here : https://drop.chapril.org/download/3a18d06ab9d7efe3/#rhJx3zXvPMWwfikWyIJaEQ
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有下载所有数据。一个小样本通常绰绰有余。我创建了数据;我使用了相同的名称,所以这应该很好地迁移到您的项目。
我看到您曾尝试使用
up
设置。你很近。您需要眼
。根据您的使用方式,它也可能导致您放大进出。因此,如果您不熟悉它的工作原理,最好开始小。我的假数据:
图B带有您的原始代码。
(fig1b&lt; -plot_ly(dataresults1ab,x = 〜n1,y = 〜n2,z = 〜n3,
type =“ sctity3d”,mode =“ lines”)%&gt;%
布局(title =“相应限制周期”,
场景= list(xaxis = list =“物种1”,range = c(0,50)),
yaxis = list(title =“物种2”,范围= C(0,50)),
zaxis = list(title =“物种3”,范围= C(0,50)),
相机= list(up = list(0,0.5,0.5)))))))
修改后的图B.
在
这里说明 href =“ https://i.sstatic.net/l1glv.png” rel =“ nofollow noreferrer”>
I didn't download all of that data. A small sample is usually more than enough. I created data; I used the same names, so this should migrate to your project pretty well.
I see that you had tried working with the
up
setting. You were close. You needed theeye
. Depending on how you use this, it can cause you to zoom in and out, as well. So it's better to start small if you're not familiar with how it works.My fake data:
Figure B with your original code.
(Fig1b<-plot_ly(dataresults1ab, x = ~N1, y = ~N2, z = ~N3,
type = "scatter3d", mode = "lines")%>%
layout(title = "The corresponding limit cycle",
scene = list(xaxis = list(title = "Species 1", range = c(0,50)),
yaxis = list(title = "Species 2", range = c(0,50)),
zaxis = list(title = "Species 3", range = c(0,50)),
camera = list(up = list(0, 0.5, 0.5)))))
Modified figure B.
A slightly less aggressive adjustment of figure B.