6/1/2023 0 Comments Gnuplot multiplot![]() The main file is then set terminal pngcairo size 800,600 background rgb '#bbbbbb'Įval(init_margins(0.1, 0.98, 0.1, 0.98, 0.08, 0. Sprintf('set bmargin at screen %f ', get_bmargin(row)) Sprintf('set tmargin at screen %f ', get_tmargin(row)). Sprintf('set rmargin at screen %f ', get_rmargin(col)). Sprintf('set lmargin at screen %f ', get_lmargin(col)). The standard way is to tell gnuplot what, where and in what size we want to plot, as in set multiplot set size 0.5, 1 set origin 0,0 plot sin (x) set origin 0.5, 0 plot cos (x) unset multiplot The problem here is that when gnuplot determines how big the actual plot is going to be, it counts the borders, axis label, tics and so on in the size. Get_bmargin(row) = (top_margin - (row - 1) * gap_size_y - row * ((top_margin - bottom_margin - gap_size_y * row_count) / row_count)) Get_tmargin(row) = (top_margin - (row - 1) * gap_size_y - (row-1) * ((top_margin - bottom_margin - gap_size_y * row_count) / row_count)) Get_rmargin(col) = (left_margin (col - 1) * gap_size_x col * ((right_margin - left_margin)-(col_count - 1) * gap_size_x)/col_count) Get_lmargin(col) = (left_margin (col - 1) * (gap_size_x ((right_margin - left_margin)-(col_count - 1) * gap_size_x)/col_count)) Sprintf('col_count = %d row_count = %d gap_size_x = %f gap_size_y = %f', cols, rows, dx, dy) Sprintf('left_margin = %f right_margin = %f top_margin = %f bottom_margin = %f ', left, right, top, bottom). ![]() You can put all the general stuff in a configuration file, like multiplot.gp, which contains the functions init_margins(left, right, bottom, top, dx, dy, rows, cols) = \ To achieve the same thing with gnuplot 4.x, you must do the calculations by hand or define some functions, like the following example shows. set terminal pngcairo size 800,600 background rgb '#bbbbbb'Įarlier versions, kept only for completeness spacing takes two number set multiplot spacing, which give the distance between two rows ( ) or two columns ( ). Margins takes four numbers set multiplot margins, which give the fixed overall margins around the multiplot layout. Since 5.0 version, multiplot has the options margins and spacing. ![]() X3MARGIN = "set lmargin at screen 0.633333 set rmargin at screen 0.Getting the margins right with multiplot is a bit tedious, especially when using set pm3d map, which has quite large margins. X2MARGIN = "set lmargin at screen 0.366667 set rmargin at screen 0.633333" X1MARGIN = "set lmargin at screen 0.100000 set rmargin at screen 0.366667" Y2MARGIN = "set tmargin at screen 0.500000 set bmargin at screen 0.100000" Generated template script Y1MARGIN = "set tmargin at screen 0.900000 set bmargin at screen 0.500000" Set multiplot layout 1Įxample without margins Generator configuration # - Configuration. YTICS = "set format y '%g' set ylabel 'Y'" XTICS = "set format x '%g' set xlabel 'X'" X3MARGIN = "set lmargin at screen 0.640000 set rmargin at screen 0.900000" multiple plots in the same figure by exploiting the multiplot command. X2MARGIN = "set lmargin at screen 0.370000 set rmargin at screen 0.630000" A named dataset comes in hand also when using gnuplot to fit experimental data to. ![]() X1MARGIN = "set lmargin at screen 0.100000 set rmargin at screen 0.360000" Y2MARGIN = "set tmargin at screen 0.495000 set bmargin at screen 0.100000" Generated template script Y1MARGIN = "set tmargin at screen 0.900000 set bmargin at screen 0.505000" # Number of lines and columns (number of plots in X and Y direction) If it is not empty, it will be placed in front of each plot-command.Įxamples Example with margins Generator configuration # - Configuration. This will be placed as a placeholder plot-command in the generated template. In this case, their will be no margins between the graphs and their axes will touch.īy default only the X- and Y-labels of the lowermost and leftmost graphs are shown. The variables plot_x_margin and plot_y_margin can be set to 0. pad_left = 0.1 will reserve 10% of the total width of the canvas on the left side for Y-Labels. These variables are given in relative units, e.g. See the image below to understand what they do. The other variables are paddings and margins. The variables lines and cols define the dimensions of the generated multiplot-matrix, where lines * cols equals the total number of graphs in the plot. # - Configuration - # Number of lines and columns (number of plots in X and Y direction) lines = 2 cols = 3 # Paddings of all four sides pad_top = 0.1 pad_bot = 0.1 pad_left = 0.1 pad_right = 0.1 # Margins between the plots plot_x_margin = 0.01 plot_y_margin = 0.01
0 Comments
Leave a Reply. |