Gnuplot, pm3d and surfaces

ぐ巨炮叔叔 提交于 2019-11-27 15:52:42

Here is an example with pseudo data:

reset 
set xrange[0:1]
set yrange[0:1]
set cbrange[0:1]
set palette defined (0 'green', 1 'red', 1 'blue', 2 'white')
set isosamples 100
set samples 100
set pm3d depthorder
set view 60,335
splot '++' using 1:2:2:(0.5*$2) with pm3d title 'red -> green',\
      '++' using 1:2:1:(0.5*(1+$1)) with pm3d title 'blue -> white'

Result:

To use data instead of these pseudo data generated by '++' you can use stats to determine the data ranges and scale the surface colors accordingly to [0:0.5] for one, and to [0.5:1] for the other.

This concept with the different color ranges to incorporate two palettes in one does work only for data files (including pseudo data files). To plot two spheres beneath each other with different colors, one can first produce a data file, which is later used for pm3d plotting:

reset 
# generate the sphere data
set samples 100
set isosamples 100
set parametric
set urange[0:2*pi]
set vrange[0:pi]
set table 'spheres.dat'
r = 0.25
splot r*cos(u)*sin(v),r*sin(u)*sin(v),r*cos(v) with lines
unset table
unset parametric

# plot the generated data set
set xrange[-1:1]
set yrange[-1:1]
set cbrange[-1:3]
set palette defined (0 'black', 1 'green', 1 'black', 2 'red')

set pm3d depthorder
unset colorbox
unset key
set ticslevel 0
set view 19,34
splot 'spheres.dat' using ($1-0.5):2:3:($3/r) with pm3d, \
      '' using ($1+0.5):2:3:($3/r + 2) with pm3d

The result is

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