如何在gnuplot中用纯白色或透明色填充曲线?

时间:2017-09-16 18:59:38

标签: graph 3d gnuplot fence-plots

只是想知道我是否可以使用不会扭曲图形功能的颜色/选项填充曲线下方的区域,我尝试过没有填充no filled并使用了实心/冲动样式filled。欢迎任何建议!

刚使用:splot w lines lc rgb“dark-violet”

2 个答案:

答案 0 :(得分:0)

这是一个丑陋的黑客,但它有点作用:绘制每个迹线两次,一次作为曲线,一次作为纯白色"墙"这将涵盖其背后的任何谎言。后者需要在三维图中轻微滥用filledcurves绘图样式。您必须手动处理深度排序,因此您必须从前到后绘制。

示例:

f(x,t)=exp(-(x-t)**2)   # some function in lieu of data

set xr [-10:20]
set yr [-0.5:10.5]
set zr [0:1]

set xlabel "x"  
set ylabel "t"
set xyplane at 0

set samples 1000
unset key

set multiplot
do for [t=10:0:-1] {
   splot  '+' using 1:(t):(f($1,t)) w filledcurves lc rgb "white" lw 1
   if (t == 10) {    # after first splot, do not plot borders and tics again
      unset border
      unset xtics
      unset ytics
      unset ztics
      unset xlabel
      unset ylabel
      unset zlabel
   }
   splot  '+' using 1:(t):(f($1,t)) w l ls 1
}
unset multiplot

给出

enter image description here

答案 1 :(得分:0)

您可以使用多边形来制作曲线 以下是使用多边形的示例:

set terminal wxt size 600,400

#set title "Graph Title"
#set xlabel "X"
#set ylabel "Y"
#set ylabel "Z"

# sets background color
set object 1 rectangle from screen -0.1,-0.1 to screen 1.1,1.1 fillcolor rgb "#ffffff" behind

# allows rendering of polygons with hidden line removal
set hidden3d back offset 0 trianglepattern 2 undefined 1 altdiagonal bentover

# displays borders 0x7F = 0b1111111
set border 0x7F linecolor rgb "#555555"

# displays the x, y and z axis
#set xzeroaxis linewidth 0.5 linetype 1
#set yzeroaxis linewidth 0.5 linetype 2
#set zzeroaxis linewidth 0.5 linetype 3

# displays the x, y and z grid
set grid xtics linecolor rgb "#888888" linewidth 0.2 linetype 9
set grid ytics linecolor rgb "#888888" linewidth 0.2 linetype 9
set grid ztics linecolor rgb "#888888" linewidth 0.2 linetype 9

# moves the x, y grid to 0
set xyplane at 0

# makes the x, y, and z axis proportional
#set view equal xyz

# moves the key out of the graph
set key outside vertical bottom right

splot "Data.dat" title "Data" with lines linewidth 1.0 linecolor rgb "#8888FF"

data.dat文件:

0.000000 0.000000 4.562285
0.000000 0.000000 0.000000

1.000000 0.000000 2.139039
1.000000 0.000000 0.000000

2.000000 0.000000 3.120719
2.000000 0.000000 0.000000


0.000000 1.000000 2.562285
0.000000 1.000000 0.000000

1.000000 1.000000 4.139039
1.000000 1.000000 0.000000

2.000000 1.000000 3.120719
2.000000 1.000000 0.000000


0.000000 2.000000 2.562285
0.000000 2.000000 0.000000

1.000000 2.000000 1.139039
1.000000 2.000000 0.000000

2.000000 2.000000 3.120719
2.000000 2.000000 0.000000

由blender和python脚本生成:
https://github.com/lowlevel86/blender-to-gnuplot

如果要读取顶点数据而不是多边形数据,也可以使用命令行工具。你可以替换" Data.dat"在gnuplot文件中:

"<grep -E '[0-9]' Data.dat | awk '{print $1 \" \"$2\" \"$3; print $1\" \"$2\" 0.0\\n\"}'"

或者

"<grep -E '[0-9]|^$' Data.dat | awk '{print (!NF)?\"\":$1 \" \"$2\" \"$3\"\\n\"$1\" \"$2\" 0.0\\n\"}'"