微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何使Gnuplot绘图了解X轴数据不在数据文件中?

如何解决如何使Gnuplot绘图了解X轴数据不在数据文件中?

我正在尝试使用splot中的Gnuplot来创建3D图表。我的数据文件只有X(时间)和Y(吞吐量)值,但是我将使用同一splot中的多个数据文件以3D方式创建它。因此,最后,X将是datafile-1,datafile-2,datafile-3等。Y是时间,Z是吞吐量。

问题是X轴不在文件中。它实际上是一个不同的文件。而且我认为splot正在理解数据已放置在文件中。我应该如何配置splot以了解我希望为不同的文件固定X轴?这是我当前的情节,带有最少的运行脚本和文件

#!/usr/bin/gnuplot

reset session

set style line 1 lc rgb '#3274D9' lt 1 lw 1.0 ps 0.4 pt 2 pi 15 # auto-combiner input    throughput - 8combines.8reducers

set style line 9 lc rgb '#3274D9' lt 1 lw 1.0 ps 0.4 pt 1 pi 15 # auto-combiner input    throughput - 16combines.16reducers

set term pdfcairo size 5.0in,3.5in
set pointintervalBox 0
set datafile separator ','
set output "efficiency-throughput-networkbuffer-TaxiRideNYC-500K-merged-3D.pdf"
set grid
myTimeFmt = "%Y-%m-%d %H:%M:%s"
set key under center maxrows 1 horizontal
set key font ",9"

set xlabel "different topologies" font ",9" rotate by -8 right offset 10,-1,0
set xrange [0:3]
set xtics 0,1 font ",8"
x0 = 0
x1 = 1
x3 = 2
x4 = 3

set ylabel "time (hour:minute)" font ",9" offset 1,0
set format y "%tH:%tM" time
set ytics font ",8" offset 0,0
set yrange [0:5400]

set zlabel "Throughput (K rec/sec)" font ",9" rotate by 90 right offset 3,0
set zrange [0:7]
set ztics nomirror font ",10"

splot t=0 "throughput-vs-networkbuffer-500K-8combiners-8reducers-all.csv" u x0:(column(2)/1000):(t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN,timecolumn(1,myTimeFmt)-t0) skip 2 title "auto-combiner input throughput (8:8)" with linespoints ls 1 \,t=0 "throughput-vs-networkbuffer-500K-16combiners-16reducers-all.csv" u x1:(column(2)/1000):(t==0?(t0=timecolumn(1,myTimeFmt)-t0) skip 2 title "auto-combiner input throughput (16:16)" with linespoints ls 9 \

数据文件throughput-vs-networkbuffer-500K-8combiners-8reducers-all.csv

time,throughputINmean,throughputINstddev,throughputOUTmean,throughputOUTstddev,outPoolAvgMean,outPoolAvgStddev,outPool99thMean,outPool99thStddev,0
"2020-06-07 23:45:00",1040.88,283.444,283.439,79.1667,14.7314,77,16.2635
"2020-06-07 23:45:15",1578.69,108.016,108.02,100,0
"2020-06-07 23:45:30",1853.13,296.748,296.756,0
"2020-06-07 23:45:45",2094.84,470.787,470.796,0
"2020-06-07 23:46:00",1775.97,249.804,1775.95,249.833,99.8264,0.245523,0
"2020-06-07 23:46:15",1459.78,24.1722,1459.76,24.2096,0
"2020-06-07 23:46:30",1429.39,7.10249,1429.37,7.12607,0
"2020-06-07 23:46:45",1425.87,18.5822,1425.84,18.6244,0
"2020-06-07 23:47:00",1415.67,0.0658002,1415.64,0.0481225,0
"2020-06-07 23:47:15",1443.3,3.15546,1443.29,3.15743,0
"2020-06-07 23:47:30",1439.04,0.594166,1439.02,0.60988,0
"2020-06-07 23:47:45",1441.54,13.7807,1441.52,13.7788,0
"2020-06-07 23:48:00",1433.19,12.0817,1433.16,12.1092,0
"2020-06-07 23:48:15",1425.33,0.860313,1425.29,0.897633,0
"2020-06-07 23:48:30",1419.75,19.4022,1419.71,19.4307,0
"2020-06-07 23:48:45",1406.29,32.193,1406.24,32.2313,0
"2020-06-07 23:49:00",1423.24,0.771925,1423.19,0.78371,99.6528,0
"2020-06-07 23:49:15",1420.64,7.01607,1420.56,7.0092,0
"2020-06-07 23:49:30",1411.63,10.9091,1411.56,10.9287,0
"2020-06-07 23:49:45",1411.94,17.4695,1411.86,17.4822,0
"2020-06-07 23:50:00",1408.83,9.79343,1408.75,9.84253,0
"2020-06-07 23:50:15",1413.76,35.4693,1413.69,35.5449,0
"2020-06-07 23:50:30",1432.11,8.61099,1431.98,8.73375,0
"2020-06-07 23:50:45",1436.48,34.7072,1436.34,34.881,0

和数据文件throughput-vs-networkbuffer-500K-16combiners-16reducers-all.csv

time,0
"2020-05-28 21:59:00",636.815,544.766,60,28.2843,28.2843
"2020-05-28 21:59:15",1021.11,247.18,1021.13,247.162,78.8542,14.9524,83.6667,11.5494
"2020-05-28 21:59:30",1415.11,41.2229,1415.1,41.2258,69.6875,21.4342,84.3333,11.078
"2020-05-28 21:59:45",1815.02,324.306,90.4167,6.77644,91.0417,6.3345
"2020-05-28 22:00:00",2051.02,481.214,481.218,92.2917,5.45062,97.5,1.76777
"2020-05-28 22:00:15",2003.74,446.739,2003.73,446.748,0
"2020-05-28 22:00:30",1844.27,342.101,1844.26,342.104,0
"2020-05-28 22:00:45",1672.59,222.094,1672.56,222.091,0
"2020-05-28 22:01:00",1489.64,98.2898,98.2967,0
"2020-05-28 22:01:15",1396.23,0.577471,1396.21,0.560284,0
"2020-05-28 22:01:30",1379.1,1.3823,1379.09,1.37542,0
"2020-05-28 22:01:45",1374.07,17.6728,1374.08,17.6885,0
"2020-05-28 22:02:00",1383.45,33.6386,1383.44,33.647,0
"2020-05-28 22:02:15",1357.17,19.0992,1357.16,19.1115,0
"2020-05-28 22:02:30",1360.52,5.2483,1360.5,5.23259,0
"2020-05-28 22:02:45",1372.18,22.3451,1372.17,22.3279,0
"2020-05-28 22:03:00",1374.21,5.27384,1374.2,5.26009,0
"2020-05-28 22:03:15",1365.91,8.53979,1365.89,8.54322,0

enter image description here

解决方法

我可以使用Gnuplot中的函数来实现。我正在使用上面的相同数据文件,此Gnuplot脚本和X轴的函数P(x)=x

#!/usr/bin/gnuplot

reset session

set style line 1 lc rgb '#3274D9' lt 1 lw 1.0 ps 0.4 pt 2 pi 15 # auto-combiner input    throughput - 8combines.8reducers

set style line 9 lc rgb '#3274D9' lt 1 lw 1.0 ps 0.4 pt 1 pi 15 # auto-combiner input    throughput - 16combines.16reducers

set term pdfcairo size 5.0in,3.5in
set pointintervalbox 0
set datafile separator ','
set output "efficiency-throughput-networkbuffer-TaxiRideNYC-500K-merged-3D.pdf"
set border 127

set xyplane at 1
set grid
#set grid x y z vertical
#set grid lt 1 lw 0.75 lc "grey"
myTimeFmt = "%Y-%m-%d %H:%M:%S"
set key under center maxrows 1 horizontal
set key font ",9"

set xlabel "different topologies" font ",9" rotate by -8 right offset 10,-1,0
set xrange [0:3]
set xtics 0,1 mirror font ",8"
P(x)=x

set ylabel "time (hour:minute)" font ",9" offset 1,0
set format y "%tH:%tM" time
set ytics mirror font ",8" offset 0,0
set yrange [0:5400]

set zlabel "Throughput (K rec/sec)" font ",9" rotate by 90 right offset 3,0
set zrange [0:7]
set ztics mirror font ",9"
set ticslevel 0 # We need this,in order to shift the 0 of the z axis

splot t=0 "throughput-vs-networkbuffer-500K-8combiners-8reducers-all.csv" u (P(0)):(t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN,timecolumn(1,myTimeFmt)-t0):(column(2)/1000) skip 2 title "auto-combiner input throughput (8:8)" with linespoints ls 1 \,t=0 "throughput-vs-networkbuffer-500K-16combiners-16reducers-all.csv" u (P(1)):(t==0?(t0=timecolumn(1,myTimeFmt)-t0):(column(2)/1000) skip 2 title "auto-combiner input throughput (16:16)" with linespoints ls 9 \

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。