Linux GNUplot 中的多重绘图
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12398708/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Multiple Plot in GNUplot
提问by user1667228
I want to do multiplot or subplot in GNUplot. I have two files that has x1, y1 in two files. I want to have two graphs plotted in GNUplot like a subplot. Suppose I have the following two files
我想在 GNUplot 中做 multiplot 或 subplot。我有两个文件,在两个文件中有 x1, y1 。我想像子图一样在 GNUplot 中绘制两个图。假设我有以下两个文件
Plot1
情节 1
12:14:38 10
12:14:38 10
12:15:38 11
12:15:38 11
12:16:38 12
12:16:38 12
12:17:38 15
12:17:38 15
and another file
和另一个文件
Plot2
情节2
12:17:38 15
12:17:38 15
12:18:38 11
12:18:38 11
12:19:38 12
12:19:38 12
12:20:38 15
12:20:38 15
I want to generate two graphs for these two values. How do i do it using GNUplot. Can anyone please help me out.
我想为这两个值生成两个图。我如何使用 GNUplot 做到这一点。任何人都可以帮助我。
Thanks
谢谢
回答by andyras
If I understand what you are asking, here is the basic syntax:
如果我明白你在问什么,这里是基本语法:
set term png size 600,400
set output 'plot.png'
set multiplot # engage multiplot mode
set size 1.0,1.0 # sets the size of the first plot
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' ##
plot 'data1' u 1:2 # plot the first data set
set size 0.4,0.4 # set the size of the second plot in plot units
set origin 0.15,0.5 # set the origin for the second plot in plot units
plot 'data2' u 1:2 # plot the second data set
This will plot the second data set as a subfigure.
这会将第二个数据集绘制为子图。
To make two plots in a grid, you can use set multiplot layout
:
要在网格中绘制两个图,您可以使用set multiplot layout
:
set term png size 600,300
set output 'plot.png'
set multiplot layout 1,2 # engage multiplot mode
#set size 1.0,1.0 # sets the size of the first plot
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 120 # make time spacing of 2 minutes
plot 'data1' u 1:2 # plot the first data set
#set size 0.4,0.4 # set the size of the second plot in plot units
#set origin 0.15,0.5 # set the origin for the second plot
plot 'data2' u 1:2 # plot the second data set
unset multiplot