简体   繁体   English

gnuplot:在球体表面上绘制 function

[英]gnuplot: Plotting a function on the surface of a sphere

I have a function, say f(theta, phi) = sqrt(1 - (sin(theta)*sin(phi))**2) + 5 * sqrt(1 - (sin(theta)*cos(phi))**2) that I want to plot as a color plot on the surface of a sphere.我有一个 function,说f(theta, phi) = sqrt(1 - (sin(theta)*sin(phi))**2) + 5 * sqrt(1 - (sin(theta)*cos(phi))**2)我想将 plot 作为颜色 plot 在球体表面上。 However, I can't figure out how I have to feed this function into splot in order to achieve this without first generating a file with the appropriate values in a table.但是,我不知道如何将这个 function 输入splot以实现这一点,而无需先在表中生成具有适当值的文件。

How can I get gnuplot to do this?我怎样才能让gnuplot做到这一点?

Instead of generating a file, you can use the special filename "++", see help special .您可以使用特殊文件名“++”而不是生成文件,请参阅help special I think the last example on the gnuplot demo page has your use case.我认为gnuplot 演示页面上的最后一个示例有您的用例。 Simplified with minor modifications:通过少量修改进行简化:

xx(u, v) = cos(v) * cos(u)
yy(u, v) = cos(v) * sin(u)
zz(u, v) = sin(v)
f(theta, phi) = sqrt(1 - (sin(theta)*sin(phi))**2) + 5 * sqrt(1 - (sin(theta)*cos(phi))**2)

set parametric
set isosamples 121, 61
set samples 121, 61
set urange [-pi:pi]
set vrange [-pi/2:pi/2]

set border 4095
set view equal xyz
set xyplane 0

splot "++" using (xx($1,$2)):(yy($1,$2)):(zz($1,$2)):(f($1,$2)) with pm3d notitle

This is the result:这是结果:

彩色球体

Please double check whether the definitions of the spherical coordinates match.请仔细检查球坐标的定义是否匹配。

This should be a comment to maij's answer, but I am not special enough to be allowed to do that.这应该是对 maij 回答的评论,但我不够特别,不能被允许这样做。

Anyway, I needed to add "set pm3d depthorder" to avoid severe clipping issues.无论如何,我需要添加“设置 pm3d depthorder”以避免严重的剪辑问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM