用于简单日期时间图的 Gnuplot

Gnuplot for a simple date-time plot

对于这个数据文件:

Server ID,Sponsor,Server Name,Timestamp,Distance,Ping,Download,Upload,Share,IP Address
4981,SELCO,"Shrewsbury, MA",2022-01-19T17:45:00.941297Z,46.02761207264913,16.34,202120227.4774976,5410786.336552021,,66.30.193.6
27031,BELD Broadband,"Braintree, MA",2022-01-19T18:45:01.962140Z,26.98449241976281,17.566,140849719.78516415,5441730.586693773,,66.30.193.6
27031,BELD Broadband,"Braintree, MA",2022-01-19T19:15:01.589345Z,26.98449241976281,17.419,156811809.4210379,5371285.306441804,,66.30.193.6
38849,FiberCast,"Stoddard, NH",2022-01-19T19:45:00.746522Z,106.41034005246897,20.042,215161640.72859222,6086086.612413734,,66.30.193.6

我想要一个图,其中第 7 列在 y 轴上,第 4 列在 x 轴上。我想让 x 轴从 2022 年 1 月 21 日到 2022 年 1 月 25 日。我希望缩放 y 轴,使 1 为 10^6。

问题与(我认为)date.time 的解析和 x 轴的缩放有关。

set datafile separator ","
set key autotitle columnhead
set terminal pdf
set output "speedtest.pdf"
set grid
#set style data lines
#set xdata time
set timefmt '%Y-%m-%d:%H:%M:%SZ'
#set xrange ["2022-01-19T00:00:00.0Z":"2022-01-24:00:00:00.0Z"]
set xrange [*:*]
plot "test.csv" using 4:7 with linespoints

Ethan 的 set datafile separator comma 和你的 set datafile separator ',' 应该是等价的。

两个小细节:

  • 您的时间格式应该是 %Y-%m-%dT%H:%M:%SZ 而不是 %Y-%m-%d:%H:%M:%SZ。找不同!
  • # 在一行的开头使其成为注释。因此,删除行 #set xdata time
  • 中的 #

对了,你也可以只输入set xrange ["2022-01-19":"2022-01-24"]。如果 gnuplot 找不到小时、分钟、秒,我猜它会假定它们为零。

检查以下稍作修改的代码。

代码:

### plotting timedata
reset session

$Data <<EOD
Server ID,Sponsor,Server Name,Timestamp,Distance,Ping,Download,Upload,Share,IP Address
4981,SELCO,"Shrewsbury, MA",2022-01-19T17:45:00.941297Z,46.02761207264913,16.34,202120227.4774976,5410786.336552021,,66.30.193.6
27031,BELD Broadband,"Braintree, MA",2022-01-19T18:45:01.962140Z,26.98449241976281,17.566,140849719.78516415,5441730.586693773,,66.30.193.6
27031,BELD Broadband,"Braintree, MA",2022-01-19T19:15:01.589345Z,26.98449241976281,17.419,156811809.4210379,5371285.306441804,,66.30.193.6
38849,FiberCast,"Stoddard, NH",2022-01-19T19:45:00.746522Z,106.41034005246897,20.042,215161640.72859222,6086086.612413734,,66.30.193.6
EOD

set datafile separator ","
set key autotitle columnhead

set xdata time
set timefmt '%Y-%m-%dT%H:%M:%SZ'
set xrange ["2022-01-19":"2022-01-24"]   # specific range
set xrange [*:*]                         # autorange
set format x "%H:%M"
set grid

plot $Data using 4:7 w lp pt 7
### end of code

结果: