英文:
Restricting gnuplot data in palette and interpolating between points (3D)
问题
以下是翻译好的内容:
我有一个包含4列数据的数据集:x,y,z,c,以及以下的gnuplot脚本来绘制数据:
set pm3d interpolate 3,3,3
set palette defined (0 "紫色", 1 "蓝色", 2 "青色", 3 "绿色", 4 "橙色", 5 "红色", 6 "棕色", 7 "黑色", 8 "灰色")
show palette gradient
sp 'datasets' u 1:2:3:4 palette lt 7 not
它生成了一个非常漂亮的图,所有数据都是小点,可以进行旋转等操作。
我的问题是,我如何限制绘图只显示颜色0和2(不修改数据文件)?
另一个问题是,如何在数据点之间进行颜色插值?
英文:
I have a dataset with 4 columns: x,y,z,c, and the following gnuplot script to plot the data:
set pm3d interpolate 3,3,3
set palette defined ( 0 "purple", 1 "blue" , 2 "cyan" , 3 "green" ,4 "orange",5 "red",6 "brown",7 "black",8 "grey" )
show palette gradient
sp 'datasets' u 1:2:3:4 palette lt 7 not
It makes a very nice plot, all data are small points, I can rotate around...etc.
My questions would be, how can I restrict the plotting to let's say colors 0 and 2 (without modifying the datafile).
The secondary question is, how could I interpolate the colors between data points?
答案1
得分: 1
-
要筛选数据点,您可以使用条件表达式
?:
来针对您的某一列,例如:使用 1:2:(($4==0 || $4==2)?$3:1/0):4
-
要保持颜色刻度正确,您需要修正
cbrange
:设置 cbrange [0:8]
-
对于插值:
set pm3d interpolate
只有两个参数。 (0,0 用于自动插值)。
因此,我的解决方案是:
设置 pm3d interpolate 0,0
设置调色板 defined ( 0 "purple", 1 "blue" , 2 "cyan" , 3 "green" ,4 "orange",5 "red",6 "brown",7 "black",8 "grey" )
第一张图片:所有数据
splot '009_d.dat' u 1:2:3:4 palette lt 7 notitle
第二张图片:受限数据,颜色不正确
splot '009_d.dat' u 1:2:(($4==0 || $4==2)?$3:1/0):4 palette lt 7 notitle
设置 cbrange [0:8]
第三张图片:受限数据,颜色正确
splot '009_d.dat' u 1:2:(($4==0 || $4==2)?$3:1/0):4 palette lt 7 notitle
第四张图片:插值 splot
splot '009_d.dat' u 1:2:3:4 palette lt 7 notitle w pm3d
英文:
-
To filter the data points, you can use the condition form
?:
for one of your column e.g.:using 1:2:(($4==0 || $4==2)?$3:1/0):4
-
To keep the color scale correct, you have to fix the
cbrange
:set cbrange [0:8]
-
For interpolation: the
set pm3d interpolate
has only two arguments. (0,0 is for automatic).
Therefore, my solution:
set pm3d interpolate 0,0
set palette defined ( 0 "purple", 1 "blue" , 2 "cyan" , 3 "green" ,4 "orange",5 "red",6 "brown",7 "black",8 "grey" )
# First image: all data
splot '009_d.dat' u 1:2:3:4 palette lt 7 notitle
# Second image: restricted data with wrong colors
splot '009_d.dat' u 1:2:(($4==0 || $4==2)?$3:1/0):4 palette lt 7 notitle
set cbrange [0:8]
# Third image: restricted data with correct colors
splot '009_d.dat' u 1:2:(($4==0 || $4==2)?$3:1/0):4 palette lt 7 notitle
# Fourth image: interpolated splot
splot '009_d.dat' u 1:2:3:4 palette lt 7 notitle w pm3d
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论