Gnuplot:x1y1 图和 x2y1 图不共享相同的 xtics

Gnuplot: x1y1 plot and x2y1 plot not sharing same xtics

我正在尝试做一个多图。以下是我与

一起使用的 4 个文件

File1.csv

,col1,col2,col3,col4,col5,col6
10,-39,   0.7,   0,   0,99.3,   0
14,-42,   0.0,   0,   0, 100,   0
42,-64,     0,   0,   0, 100,   0
46,-67,   2.5,   0,   0,97.5,   0
50,-69,   7.6,   0,   0,92.4,   0
54,-75,     0,   0,   0, 100,   0
58,-78,   3.7,   0,   0,96.3,   0
62,-82,  69.0,   0,   0,31.0,   0
66,-85,     0,   0,   0,   0,   0
70,-100,0,0,0,0,0
74,-100,0,0,0,0,0
70,-100,0,0,0,0,0
66,-100,0,0,0,0,0
62,-100,0,0,0,0,0
58,-78,   2.1,   0,   0,97.9,   0
54,-74,   2.9,   0,   0,97.1,   0
50,-69,   2.3,   0,   0,97.7,   0
46,-65,   2.4,   0,   0,97.6,   0
42,-65,     0,   0,   0, 100,   0
14,-43,   1.5,   0,   0,98.5,   0
10,-40,   1.0,   0,   0,99.0,   0

File2.csv

,col1,col2,col3,col4,col5,col6
10,-39,   0.7,   0,   0,99.3,   0
14,-42,   0.0,   0,   0, 100,   0
42,-64,     0,   0,   0, 100,   0
46,-67,   2.5,   0,   0,97.5,   0
50,-69,   7.6,   0,   0,92.4,   0
54,-75,     0,   0,   0, 100,   0
58,-78,   3.7,   0,   0,96.3,   0
62,-82,  69.0,   0,   0,31.0,   0
66,-85,     0,   0,   0,   0,   0
70,-100,0,0,0,0,0
74,-100,0,0,0,0,0
70,-100,0,0,0,0,0
66,-100,0,0,0,0,0
62,-100,0,0,0,0,0
58,-78,   2.1,   0,   0,97.9,   0
54,-74,   2.9,   0,   0,97.1,   0
50,-69,   2.3,   0,   0,97.7,   0
46,-65,   2.4,   0,   0,97.6,   0
42,-65,     0,   0,   0, 100,   0
14,-43,   1.5,   0,   0,98.5,   0
10,-40,   1.0,   0,   0,99.0,   0

File3.csv

,col1,col2,col3,col4,col5,col6
10,-39,   0.7,   0,   0,99.3,   0
14,-42,   0.0,   0,   0, 100,   0
42,-64,     0,   0,   0, 100,   0
46,-67,   2.5,   0,   0,97.5,   0
50,-69,   7.6,   0,   0,92.4,   0
54,-75,     0,   0,   0, 100,   0
58,-78,   3.7,   0,   0,96.3,   0
62,-82,  69.0,   0,   0,31.0,   0
66,-85,     0,   0,   0,   0,   0
70,-100,0,0,0,0,0
74,-100,0,0,0,0,0
70,-100,0,0,0,0,0
66,-100,0,0,0,0,0
62,-100,0,0,0,0,0
58,-78,   2.1,   0,   0,97.9,   0
54,-74,   2.9,   0,   0,97.1,   0
50,-69,   2.3,   0,   0,97.7,   0
46,-65,   2.4,   0,   0,97.6,   0
42,-65,     0,   0,   0, 100,   0
14,-43,   1.5,   0,   0,98.5,   0
10,-40,   1.0,   0,   0,99.0,   0

File4.csv

,col1,col2,col3,col4,col5,col6
10,-39,   0.7,   0,   0,99.3,   0
14,-42,   0.0,   0,   0, 100,   0
42,-64,     0,   0,   0, 100,   0
46,-67,   2.5,   0,   0,97.5,   0
50,-69,   7.6,   0,   0,92.4,   0
54,-75,     0,   0,   0, 100,   0
58,-78,   3.7,   0,   0,96.3,   0
62,-82,  69.0,   0,   0,31.0,   0
66,-85,     0,   0,   0,   0,   0
70,-100,0,0,0,0,0
74,-100,0,0,0,0,0
70,-100,0,0,0,0,0
66,-100,0,0,0,0,0
62,-100,0,0,0,0,0
58,-78,   2.1,   0,   0,97.9,   0
54,-74,   2.9,   0,   0,97.1,   0
50,-69,   2.3,   0,   0,97.7,   0
46,-65,   2.4,   0,   0,97.6,   0
42,-65,     0,   0,   0, 100,   0
14,-43,   1.5,   0,   0,98.5,   0
10,-40,   1.0,   0,   0,99.0,   0

我得到的Gnuplot脚本是x1y1轴上的直方图和x2y1轴上的线点图

set colors classic
set terminal png notransparent size 1800,640 truecolor medium
set output 'reading.png'
set grid front

set tmargin -1; set bmargin -1
set lmargin -1; set rmargin -1

set style data histogram
set style histogram rowstacked
set style fill solid
set boxwidth 0.5
set datafile separator ","

set xtics axis
set yrange [0:100]
set y2range [-100:-10]
set y2tics
set y2label "Y2Label"
set ylabel "YLabel"
set multiplot layout 4,1 

unset xtics 
unset key
plot for [COL=3:6] 'file1.csv' u COL:xtic(1) axes x1y1 ti col,'' u 2:xtic(1) with linespoint axes x1y2
plot for [COL=3:6] 'file2.csv' u COL:xtic(1) axes x1y1 ti col,'' u 2:xtic(1) with linespoint axes x1y2
plot for [COL=3:6] 'file3.csv' u COL:xtic(1) axes x1y1 ti col,'' u 2:xtic(1) with linespoint axes x1y2
set key below
set xtics
plot for [COL=3:6] 'file4.csv' u COL:xtic(1) ti col,'' u 2:xtic(1) with linespoint axes x1y2

unset multiplot

我得到的结果图在 x-axis 上有不同的起点。有人可以帮助同步直方图和线点图吗?

我可以重现你的结果。马上,我不知道为什么会发生这种转变。可能是索引从 0 或 1 开始的东西。可能是 header 线或直方图样式与线点图相结合的东西。

可能的解决方法是使用第 0 列,即 ([=11=]-1)(参见 help pseudocolumns)作为线点图的 x 坐标。 顺便说一下,你不必多次使用 xtic(1),反正都是一样的。

您的绘图命令将缩短为:

plot for [COL=3:6] 'file1.csv' u COL axes x1y1 ti col, '' u ([=10=]-1):2 w lp axes x1y2
plot for [COL=3:6] 'file2.csv' u COL axes x1y1 ti col, '' u ([=10=]-1):2 w lp axes x1y2
plot for [COL=3:6] 'file3.csv' u COL axes x1y1 ti col, '' u ([=10=]-1):2 w lp axes x1y2
set key below
set xtics
plot for [COL=3:6] 'file4.csv' u COL axes x1y1 ti col, '' u ([=10=]-1):2:xtic(1) w lp axes x1y2