在gnuplot中包括实线和虚线轮廓

时间:2014-04-05 14:18:24

标签: gnuplot

我在gnuplot脚本中有以下内容:

set pm3d
unset surface
set pm3d map
set style line 1 lt 1 lc rgb "white"
set style line 2 lt 1 lc rgb "white"
set style line 3 lt 1 lc rgb "white"
set style line 4 lt 1  lc rgb "red"
set style line 5 lt 1  lc rgb "blue"
set style line 6 lt 2  lc rgb "white"
set style line 7 lt 2  lc rgb "white"
set style line 8 lt 2  lc rgb "white"
set style line 9 lt 2  lc rgb "white"
set style increment userstyles
set contour base
set cntrparam levels 8
set cntrparam levels discrete -8*0.0004946, -6*0.0004946, -4*0.0004946,     -2*0.0004946,    -2*0.0004946, 4*0.0004946, 6*0.0004946, 8*0.0004946
set nokey
splot '/data/ltl21/Data/PDB/HDFNI/BlindSurvey/imageresults/spectrum/HDF1map:189.20135-62.20442' u 1:2:3

这样,我想为负值绘制虚线轮廓,为正值绘制实线轮廓。我可以用上面的精细改变轮廓的颜色,虽然我希望它们都是白色的,但它似乎根本不使用它,它只是选择自己的线条样式并使用它..

有谁知道如何指定各个轮廓的线型?

干杯

2 个答案:

答案 0 :(得分:0)

同样的问题刚出现在我面前。这是我在http://www.gnuplot.info/faq/faq.html找到的一个很好的解决方法:

gnuplot> # An example. Place your definition in the following line:  
gnuplot> f(x,y) = y - x**2 / tan(y)  
gnuplot> set contour base  
gnuplot> set cntrparam levels discrete 0.0  
gnuplot> unset surface  
gnuplot> set table ’curve.dat’  
gnuplot> splot f(x,y)  
gnuplot> unset table  
gnuplot> plot ’curve.dat’ w l

将splot与您的标准选项一起使用。您可以在一个文件中保存多个轮廓。同一文件中的每个轮廓将以相同的样式绘制。 您可以像往常一样设置绘图选项:linestyle,linetype等。这就是我如何使用它:

gnuplot> set cntrparam levels discrete 0,1,2,3 
gnuplot> set style line 1 lt 2 lw 4 lc rgb "cyan"
gnuplot> set table 'mycontours.dat'
gnuplot> splot 'mydata.dat' matrix 
gnuplot> unset table
gnuplot> plot 'mycontours.dat' ls 1

它在epslatex中返回了4个虚线青色轮廓。您似乎需要为不同的轮廓样式保存到不同的文件(或手动编辑文件)。

答案 1 :(得分:0)

multiplot可用于解决此问题:

set pm3d
unset surface
set pm3d map
set view map
set key center rmargin
set dgrid3d 15,31
set hidden3d
set contour base
set nosurface
set grid lw 1 lc rgb 'gray'

f(x,y) = x*y

set nokey

set cntrparam levels discrete 2, 4, 6, 8

set linetype 1  lc rgb '#0042ad' lw 1.3
set linetype 2  lc rgb '#0060ad' lw 3.1
set linetype 3  lc rgb '#007cad' lw 31
set linetype 4  lc rgb '#0099ad' lw 0.31

set cntrlabel start 25 interval -1 font 'arial, 1'
set style textbox noborder

set multiplot

splot  f(x,y) w l title ''

unset pm3d
set linetype 1  lc rgb '#00ada4' lw 2 dashtype 2
# notice how changing 'lw' or 'dashtype' does not have any effect after first use:
set linetype 2  lc rgb '#00ad88' lw 1 dashtype 1
set linetype 3  lc rgb '#00ad6b' lw 3 dashtype 4
set linetype 4  lc rgb '#eeeeee' lw 4 dashtype 3
set cntrparam levels discrete -8, -6, -4, -2
splot  f(x,y) w l

unset multiplot

取消设置pm3d至关重要,否则它将覆盖第一个splot命令的行。