gnuplot:在球体表面上绘制函数 [英] gnuplot: Plotting a function on the surface of a sphere

查看:146
本文介绍了gnuplot:在球体表面上绘制函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个函数,例如 f(theta,phi)= sqrt(1-(sin(theta)* sin(phi))** 2)+ 5 * sqrt(1-(sin(theta)我想将* cos(phi))** 2)绘制为球面上的颜色图.但是,如果不先在表中生成具有适当值的文件,就无法弄清楚如何将此函数提供给 splot 来实现此目的.

如何获取 gnuplot 来做到这一点?

解决方案

您可以使用特殊文件名"++"代替生成文件,请参见帮助特殊文件.我认为

请仔细检查球坐标的定义是否匹配.

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. 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.

How can I get gnuplot to do this?

解决方案

Instead of generating a file, you can use the special filename "++", see help special. I think the last example on the gnuplot demo page has your use case. 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.

这篇关于gnuplot:在球体表面上绘制函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆