GNUPLOT: Plotting on the surface of a sphere

久未见 提交于 2019-12-18 02:57:10

问题


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:

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.


回答1:


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

set pm3d depthorder



回答2:


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


来源:https://stackoverflow.com/questions/28627187/gnuplot-plotting-on-the-surface-of-a-sphere

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!