Xl, yl, zl =spheric2cartesian( rg, (thetar_M+t_plus)*np.ones(30), np.linspace(phir_m-t_plus, phir_M+t_plus, 30))Ĭoloraxis=dict(colorscale=colorscale, showscale=False), Xl, yl, zl =spheric2cartesian(np.linspace(0, R+r_plus, 10), thetar_M+t_plus, p) Xl, yl, zl =spheric2cartesian(np.linspace(0, R+r_plus, 10), t, phir_M+t_plus) X, Y, Z = spheric2cartesian (rp, thetap, phip)įig.add_scatter3d(x=X, y=Y, z=Z, mode="markers", Phip= phir_m +(phir_M-phir_m)* np.random.rand(n) Thetap = thetar_m + (thetar_M-thetar_m) *np.random.rand(n) #Generate points to be ploted with respect to spheric layout Xb, yb, zb = spheric2cartesian(rp, Theta, Phi) Theta = (thetar_M+t_plus)*np.ones(rp.shape) Phi = np.linspace(phir_m-t_plus, phir_M+t_plus, 75) #plot the sector, equivalent to the plane behind the points in cartesian axes Lightposition=lightposition)) #The floor of the plot Xb, yb, zb = spheric2cartesian(rm, theta, phi) Theta = np.linspace(thetar_m-t_plus, thetar_M+t_plus, 50) equivalent to the plane z=cst for cartesian axes #define the circular sector under the scatter points, i.e. T_plus=0.05 # to be substracted/added to thetar and phir to avoid points lying on the sector of coordinates R_plus =0.1 #a small amount to be added to the radius Phir_m, phir_M = deg2radians(phi_m), deg2radians(phi_M)Ĭolorscale=,] Thetar_m, thetar_M = deg2radians(theta_m), deg2radians(theta_M) import aph_objects as goįrom import Rotation as Rot You must adapt it to your data, and add ticklabels as 3D annotations. It’s not a smart code (it isn’t parameterized), but just one that works to illustrate what could be mathematically reasonable for such a layout. I suppose that you intend to use such a layout for a single plot, because otherwise it is a nightmare to generate it, since Plotly has no definition for it. It is included in the plane where phi coords are constant and equal to the phi- max value. The “floor” of the “sectors” of coordinates is not horizontal, like the plane z=min(zdata) in a cartesian system. As you can see it depends on data plotted as spheric scatter3d. Referencing the points given in spherical coordinates, to the cartesian system, xOyz, allows to estimate visually its r, phi and theta tried to define a layout for spherical coordinates. Finally r is the distance from P to origin (the sphere center). For a point P(x,y,z), phi is the angle between Oz and OP, theta is the angle measured within the plane xOy, between OP’ and Ox, where P’ is the orthogonal projection of P onto the plane xOy (i.e. X, y, z = spheric2cartesian (r, theta, phi)įig = go.Figure(go.Scatter3d(x=x, y=y, z=z, mode="markers", marker_size=3))įig.update_layout(width=600, height=600, scene_camera_eye=dict(x=1.5, y=-1.5, z=1), scene_aspectmode="data")Ī spherical system of coordinates is a curvilinear one, hence don’t expect to plot “special axes” associated to r, theta and phi. Phi= phi_m +(phi_M-phi_m)* np.random.rand(n) Theta = theta_m + (theta_M-theta_m) *np.random.rand(n) #generate n points within a spherical sector There is no special px function that generates a 3d scatter plot from points given in spherical coordinates, but it is simple to define a function that converts the spheric to cartesian coordinates, and to plot the corresponding points: import aph_objects as go
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |