# Plotting cartesian coordinate data point in spherical coordinate

 I have field value in cartisian coordinate i.e. {x,y,z,Ex,Ey,Ez}=


{{-6.1935, 0.1505, -6.4695, 41186.7, 68876.6, -8859.19}, {-5.5125, 0.1505, -6.4695, 3914.28, 149235, 15848.8}, {-4.8315, 0.1505, -6.4695, -12290.5, 16073.4, 3135.46}, {-4.1505, 0.1505, -6.4695, -14043.7, -95001.8, -16983}, {-3.4695, 0.1505, -6.4695, 36911.1, 57960.9, 6953.94}, {-2.7885, 0.1505, -6.4695, -20771.9, 41121.2, -13638.4}, {-2.1075, 0.1505, -6.4695, -18273.4, 27652.3, -21044.5}} I want to plot it in a spherical coordinate. Plese suggest it.

• What have you tried so far? And I assume that's a vector field?
– ktm
Feb 28, 2020 at 17:36
• @user6014, yes you can assume. Feb 28, 2020 at 21:14
• What exactly do you want to plot? How do you want the {Ex,Ey,Ez} portions of the set to be represented? Feb 29, 2020 at 18:52
• @CA, yes If want to plot it in term of spherical (r,theta,pi, E), you can take resultent of Ex,Ey and Ez. Feb 29, 2020 at 20:28
• Yes, definitely, but what do you want to do with them? You have consistently not answered this point. Take the resultant and do what? Color them? Make an arrow? If so, what does each argument influence? Is it a direction in a coordinate system with respect to the spherical coordinates? Please, be specific. Mar 1, 2020 at 0:08

I welcome you to clarify your question a bit further as to what exactly you want to do with the data, and I will update this answer a bit further. For now, I invite you to see the following method for converting your coordinates to spherical ones:

Given a set of data

set = {{-6.1935, 0.1505, -6.4695, 0, 1, .01}, {-5.5125, 0.1505, -6.4695, 0,
1.1, .04}, {x, y, z, Ex, Ey, Ez}};


We can convert merely the first three entries of each item in the list using ToSphericalCoordinates and rejoin the list up

{ToSphericalCoordinates@set[[All, ;; 3]], set[[All, -3 ;;]]} //
Transpose // Join @@@ # &

(*{{8.95748, 2.37784, 3.1173, 0, 1, 0.01}, {8.50087, 2.43571, 3.1143, 0,
1.1, 0.04}, {Sqrt[x^2 + y^2 + z^2], ArcTan[z, Sqrt[x^2 + y^2]],
ArcTan[x, y], Ex, Ey, Ez}}*)


From here, we can use similar techniques using Part in order to plot with the coordinates being styled by the E-values.

As an update, using your new set of data, you can play with this a bit more:

set = {{-6.1935, 0.1505, -6.4695, 41186.7,
68876.6, -8859.19}, {-5.5125, 0.1505, -6.4695, 3914.28, 149235,
15848.8}, {-4.8315, 0.1505, -6.4695, -12290.5, 16073.4,
3135.46}, {-4.1505,
0.1505, -6.4695, -14043.7, -95001.8, -16983}, {-3.4695,
0.1505, -6.4695, 36911.1, 57960.9, 6953.94}, {-2.7885,
0.1505, -6.4695, -20771.9, 41121.2, -13638.4}, {-2.1075,
0.1505, -6.4695, -18273.4, 27652.3, -21044.5}};
colorSystem = RGBColor;
setsplit = {set[[All, ;; 3]],
colorSystem[#/Norm[#]] & /@ set[[All, -3 ;;]]} // Transpose //
Join@# &;
Graphics3D[{Directive[#[[2]]], Point[#[[1]]]} & /@ setsplit,
PlotRange -> {{-10, 10}, {-10, 10}, {-10, 10}}]


While the color changes, your coordinates don't seem to change much in terms of on a spherical surface. This should work pretty readily with your whole set of data as long as you name it set. You can change the color system used by changing the value of colorSystem.

• Thanks, I have uploaded more data points. Still, I am not able to plot in spherical coordinate Feb 29, 2020 at 15:02
• This still does not explain what you want to do. What do you want to do exactly? Be precise & update your question, please? You can easily plot in spherical coordinates with this method, even easier is to use your unmodified data. Feb 29, 2020 at 17:18
• @GopalVerma see update :) Mar 2, 2020 at 7:04