Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting the camera setting for a 3d using Plotly in Julia

I have a surface and a point in a 3D plot which is interactive. But I would like to change the angle of the first view one sees at the beginning such that the surface appears to be a line. I can't change the surface because that is based on given data. So I need to find a way to set camera settings. I have found that this is possible while using R and Python but how does it work with Julia?

Could somebody help me?

Here is a simple code example:

using Plotly

x = [-10,-10,10];
y = [-10,10,-10];
z = [10,-5,-10];
trace1 = mesh3d(color = "red",x=x,y=y,z=z,scaleratio = 1)
trace2 = Plotly.scatter3d(color = "blue";x=[3], y=[1],z = [2], mode="markers")
layout = Layout(;scene=attr(;xaxis=attr(;range=[-10, 10]),yaxis=attr(;range=[-10, 10]),zaxis=attr(;range=[-10, 10]), aspectratio=attr(x=1, y=1, z=1)))
plt = Plotly.plot([trace1,trace2],layout)
like image 517
Kirsten93 Avatar asked Oct 16 '25 16:10

Kirsten93


1 Answers

I found a way using Plots with the backend pylplot(). In case anybody else is interested in this I'm posting the solution:

pyplot()

angle1 = 10;
angle2 = 30; 

x = [-10,-10,10];
y = [-10,10,-10];
z = [10,-5,-10];
plt = surface([(x[1],y[1],z[1]),(x[2],y[2],z[2]),(x[3],y[3],z[3])],alpha=.1, fillalpha=.1, camera = (angle1,angle2), xlabel = "x", ylabel = "y", zlabel = "z")
like image 92
Kirsten93 Avatar answered Oct 18 '25 19:10

Kirsten93