Gnuplot 一个图中的多个文件

Gnuplot Multiple files in one Plot

我使用 gnuplot 在单个图形 (png) 上绘制来自 4 个文件的数据。

我得到 4 个图作为不同颜色的线条。

我希望它们具有不同的线条类型,以便在黑白打印输出 中可以轻松识别情节。

怎么做?非常感谢您的帮助。

所以我想要的是http://gnuplot.sourceforge.net/demo/lines_arrows.html:第二个数字。在 Gnuplot 中,我将绘图显示为不同颜色的线条。

不完全确定你的问题的哪个细节是你正在努力解决的方面。从多个文件绘图时,您可以使用 plot 'FILENAME' using COLUMNS ... , 'FILENAME2' using COLUMNS ...

指定

从您发布的示例中,我看到只要 lt -1 留在其中,线条就是黑色的。如果将其取出,事情就会变得五颜六色。 linespoints 本质上是用线连接点,在上拉到 set style func linespoints 的示例中,这在这里不起作用,因为它不是绘制的函数。

根据您链接的示例,我建议这样做:

set title ""
set xlabel ""
set bmargin 6
set offset .05, .05
set xrange [-0.5:3.3]

plot 'd1' using 1:2 lt -1  pt 6 ps 2 title 'pt 6' with linespoints,\
     'd2' using 1:2 lt -1  pt 5 ps 2 title 'pt 5' with linespoints,\
     'd3' using 1:2 lt -1  pt 7 ps 2 title 'pt 7' with linespoints,\
     'd4' using 1:2 lt -1  pt 4 ps 2 title 'pt 4' with linespoints

其中 d1 看起来像:

-0.5  0.8775825619
-0.4  0.921060994
-0.3  0.9553364891
-0.2  0.9800665778
-0.1  0.9950041653
 0.0  1.0000000000
 0.1  0.9950041653
 0.2  0.9800665778
 0.3  0.9553364891
 0.4  0.921060994
 0.5  0.8775825619
 0.6  0.8253356149
 0.7  0.7648421873
 0.8  0.6967067093
 0.9  0.6216099683
 1.0  0.5403023059
 1.1  0.4535961214
 1.2  0.3623577545
 1.3  0.2674988286
 1.4  0.1699671429
 1.5  0.0707372017
 1.6 -0.0291995223
 1.7 -0.1288444943
 1.8 -0.2272020947
 1.9 -0.3232895669
 2.0 -0.4161468365
 2.1 -0.5048461046
 2.2 -0.5885011173
 2.3 -0.6662760213
 2.4 -0.7373937155
 2.5 -0.8011436155
 2.6 -0.8568887534
 2.7 -0.904072142
 2.8 -0.9422223407
 2.9 -0.9709581651
 3.0 -0.9899924966
 3.1 -0.9991351503
 3.2 -0.9982947758
 3.3 -0.9874797699

编辑:

感谢您的澄清。多一些指点

颜色本身:我建议 http://colorbrewer2.org/ 选择 "photocopy safe" 的颜色。即使以灰度打印,这些也很容易区分。

标记:带有点类型,例如pt 5 您可以为数据指定不同的标记。我在上面的例子中用 ps 2 改变了大小。特别是空心标记和实心标记很容易相互区分。

线型:您需要 gnuplot 版本 5:

New features in version 5 * The dot-dash pattern of a line can now be specified independent of other line properties. See dashtype (p. 37), set dashtype (p. 115), set linetype (p. 135).

如果不升级,我无法将其转换为 运行,它源自您链接的页面:

set termoption dash
unset colorbox
set title ""
set xlabel ""
set bmargin 6
set offset .05, .05
set xrange [-0.5:3.3]
show style line

plot 'd2' using 1:2 with linespoints dt 2 lw 3 lc rgb "black" ps -1,\
   'd3' using 1:2 with linespoints dt 1      lc rgb "black" ps -1,\
   'd4' using 1:2 with linespoints dt 3      lc rgb "black" ps -1

这里dt是dash type的缩写,lw是线宽,lc是线色我设置为黑色,ps是point style,禁用,所以我们看不到点,只看到线