如何在GNUplot中将两个图形叠加到一个图中

5

我有两个文件,它们的x轴是时间,y轴是数值。我需要将这两个文件叠加在同一个图中。目前我尝试使用GNUplot,但卡在了中间。以下是一个样本文件:

01:03:05    6

01:03:15    6

还有另一个文件

01:03:55    6

01:04:10    6

我需要在同一张图中绘制这两个文件(用不同的符号区分),与GNUplot相关。我不知道是否可以实现。目前我为每个文件创建了两个网格。但我需要它们都在同一张图中。以下是我的代码:

set multiplot layout 1,2    # engage multiplot mode

set xdata time          ## these three lines control how gnuplot

set timefmt '%H:%M:%S'  ## reads and writes time-formatted data.

set format x '%H:%M:%S' ##

set xtics 05           # make time spacing of 2 minutes

plot 'AAA' u 1:2      # plot the first data set 

plot 'BBB' u 1:2      # plot the second data set 

unset multiplot

有没有熟悉GNUplot或其他在Linux上工作的工具的人可以帮我?

1个回答

11

为了在一个图中绘制多条线,请将它们放入单个plot命令中,例如:

plot 'AAA' u 1:2, 'BBB' u 1:2

有很多示例可以帮助你开始使用gnuplot。例如,这个示例展示了如何在一个图中绘制多条线。


你在脚本中使用的multiplot命令也可以像这里所示那样拥有多个绘图窗口。你可以通过以下方式调整每个子图的位置:

set size XSIZE,YSIZE        #see `help set size` 
set origin XORIGIN,YORIGIN  #see `help set origin`

或(如果您拥有gnuplot 4.2或更新版本):

set lmargin at screen XMIN  #see `help margin`
set rmargin at screen XMAX
set tmargin at screen YMAX
set bmargin at screen YMIN

你可以指出每个“subplot”的位置可以通过set originset size(或者替代选项set lmargin at screen ...set rmargin at screen ...等)进行调整 - 虽然,在这里我会选择第一种选项... - mgilson
@mgilson 随意编辑我的帖子^^。我只是觉得,Raj并不真正想要一个“multiplot”在gnuplot的意义上... - Woltan
1
我只是想指出,http://t16web.lanl.gov/Kawano/gnuplot/plot3-e.html 上的链接是403 Forbidden。 - Gerard

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接