Gnuplot 5.2绘图:一个绘图调用中包含多个pm3d调色板 [英] Gnuplot 5.2 splot: Multiple pm3d palette in one plot call

查看:398
本文介绍了Gnuplot 5.2绘图:一个绘图调用中包含多个pm3d调色板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道,我可以在绘图中使用两个不同的pm3d调色板吗?我使用Gnuplot 5.2和 想要显示两个3D曲面,例如海洋和陆地具有不同的调色板.我可以用以下方式定义它吗:

I wonder, can I used two different pm3d palettes in splot? I use Gnuplot 5.2 and want to show two 3D surfaces, like ocean and land with different color palettes. Can I define this in some way like:

splot "file" u 1:2:3 with pm3d palette 1, "file" 1:2:4 with pm3d palette 2

第1列和第2列中的数据是从0到100的整数,它们定义了一个网格.对于不同的地图,边界可能不同. z轴值是实数,表示对数刻度上的相对变化,范围从-10到10.

The data in column 1 and 2 are integers that extend from 0 to 100, they define a grid. The boundaries may be different for different maps. The z axis values are real numbers representing relative changes on logarithmic scale and extend from -10 to 10.

推荐答案

以下可能是您的解决方案.我看不到如何在splot命令中更改调色板.因此,解决方法的基本思想是通过可以为每个splot-(sub)命令设置不同的公式来设置线色.希望您可以根据需要修改以下示例.

The following might be solution for you. I do not see how to change the palette within a splot command. So, the basic idea of the workaround is to set the linecolor via formulae which can be set differently for each splot-(sub)command. I hope you can adapt the example below to your needs.

还要检查help rgbformulae并键入show palette rgbformulae,这将向您显示调色板后面的公式.

Also check help rgbformulae and type show palette rgbformulae which will show you the formulae behind the palettes.

代码:

### multiple "palettes" within one splot command
reset session

set samples 101,101
set isosamples 101,101 

f(x,y) = sin(1.3*x)*cos(0.9*y)+cos(.8*x)*sin(1.9*y)+cos(y*.2*x)
set table $Data01
    splot f(x,y)
unset table

g(x,y) = y
set table $Data02
    splot g(x,y)
unset table

h(x,y) = 0.5*x
set table $Data03
    splot h(x,y)
unset table

Zmin = -3
Zmax= 3

set xrange[-5:5]
set yrange[-5:5]
set zrange[Zmin:Zmax]
set hidden3d
set angle degree

Frac(z) = (z-Zmin)/(Zmax-Zmin)
# MyPalette01
Red01(z) = 65536 * ( Frac(z) > 0.75 ? 255 : int(255*abs(2*Frac(z)-0.5)))
Green01(z) = int(255*sin(180*Frac(z)))*256
Blue01(z) = int(255*cos(90*Frac(z)))
MyPalette01(z) =  Red01(z) + Green01(z) + Blue01(z) 

# MyPalette02
Red02(z)   = 65536 * int(255*Frac(z))
Green02(z) = 256 * (Frac(z) > 0.333 ? 255 : int(255*Frac(z)*3))
Blue02(z)  = (Frac(z) > 0.5 ? 255 : int(255*Frac(z)*2))
MyPalette02(z) =  Red02(z) + Green02(z) + Blue02(z) 

# MyPalette03
Red03(z)   = 65536 * (Frac(z) > 0.5 ? 255 : int(255*Frac(z)*2))
Green03(z) = 256 * (Frac(z) > 0.333 ? 255 : int(255*Frac(z)*3))  
Blue03(z)  = int(255*Frac(z)) 
MyPalette03(z) =  Red03(z) + Green03(z) + Blue03(z) 

set view 44,316
splot $Data01 u 1:2:3:(MyPalette01($3)) w l lc rgb var notitle, \
      $Data02 u 1:2:3:(MyPalette02($3)) w l lc rgb var notitle, \
      $Data03 u 1:2:3:(MyPalette03($3)) w l lc rgb var notitle
### end of code

结果:

这篇关于Gnuplot 5.2绘图:一个绘图调用中包含多个pm3d调色板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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