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
Plot1
12:14:38 10
12:15:38 11
12:16:38 12
12:17:38 15
and another file
Plot2
12:17:38 15
12:18:38 11
12:19:38 12
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.
Thanks
5.9 Does gnuplot support multiple y-axes on a single plot? Yes. 2D plots can have separate x axes at the bottom (x1) and top (x2), and separate y axes at the left (y1) and right (y2).
Grid Plots Next, we'll try to plot some graphs as a grid, that is, multiplots with multiple columns. Here, we will create a multiplot with 4 plots, we will make it a 2×2 grid, which means nrows=2 and ncols=2, with each image being identified by the index again, in a row-major order.
To plot functions simply type: plot [function] at the gnuplot> prompt. Discrete data contained in a file can be displayed by specifying the name of the data file (enclosed in quotes) on the plot or splot command line. Data files should have the data arranged in columns of numbers.
splot is the command for drawing 3-d plots (well, actually projections on a 2-d surface, but you knew that). It can create a plot from functions or a data file in a manner very similar to the plot command. See plot (p. ) for features common to the plot (p. ) command; only differences are discussed in detail here.
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 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With