Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GNUPLOT: Plotting on the surface of a sphere

I have a function dependent on phi and theta, which I want to plot on the surface of a sphere. The date is stored in a .txt file with the columns:

1: x = R*sin(theta)*cos(phi)
2: y = R*sin(theta)*sin(phi)
3: z = R*cos(theta)
4: density

I use the following gnuplot code to plot:

set terminal wxt size 800,800
set mapping cartesian
set view equal xyz
set xlabel 'x'
set ylabel 'y'
set zlabel 'z'
splot "densityprofile_100.000.txt" u 1:2:3:4 with pm3d
pause -1

Unfortunately Gnuplot doesn't seem to be able to properly represent the colours on the sphere. There seems to be some shadow, which I can not get rid off; see the picture here:

enter image description here

When I turn the sphere with my mouse, the shadow gets smaller and bigger, but there is no position in which it fully disappears. Any help is appreciated.

like image 325
Klamauk Avatar asked Feb 20 '15 10:02

Klamauk


2 Answers

I found the solution to my problem by adding the following line:

set pm3d depthorder
like image 147
Klamauk Avatar answered Nov 06 '22 05:11

Klamauk


At a guess, maybe the depth ordering is causing some trouble. Have you tried the pm3d "hidden3d" option?

from the gnuplot help on pm3d:

The option hidden3d takes as the argument a linestyle which must be created by set style line .... (The style need not to be present when setting pm3d, but it must be present when plotting). If set, lines are drawn using the specified line style, taking into account hidden line removal. This is by far more efficient than using the command set hidden3d as it doesn't really calculate hidden line removal, but just draws the filled polygons in the correct order. So the recommended choice when using pm3d is

 set pm3d at s hidden3d 100
 set style line 100 lt 5 lw 0.5
 unset hidden3d
 unset surf
 splot x*x+y*y
like image 1
Daniel Avatar answered Nov 06 '22 07:11

Daniel