Gnuplot 5.0 patchlevel 4 - passing column numbers in a macro - gnuplot

I have a data file (see below) with a dozen columns and I am only interested in plotting two columns (say, 5 and 10) when the values in column 1 are over a given interval. To do so, I have defined:
inter(min,max,var,colx)=(min<=column(var)&&column(var)<=max?column(colx):NaN)
Everything works as expected using plot 'data.dat' u (inter(0.25,0.5,1,5)):10 which plots columns 5 and 10 over the [0.25:0.5] interval of values in column 1.
As I need to plot various couples of columns over various intervals, I have created a file, PlotInterval.p, containing
inter(min,max,var,colx)=(min<=column(var)&&column(var)<=max?column(colx):NaN)
plot ARG1 u (inter(ARG2,ARG3,ARG4,ARG5)):ARG6
and when I call it with call 'PlotInterval.p' 0.25 0.5 1 5 10 then I get the error message:
gnuplot> call 'PlotInterval.p' 'data.dat' 0.25 0.5 1 5 10
"PlotInterval.p", line 3: warning: no column with header "1"
"PlotInterval.p", line 3: warning: partial match against column 6 header "1.451433e-005"
gnuplot> plot ARG1 u (inter(ARG2,ARG3,ARG4,ARG5)):ARG6
^
"PlotInterval.p", line 3: x range is invalid
It appears the column numbers are not passed properly (the min and max values of the interval are passed properly).
Here are the first lines of data.dat:
0.000000e+000 -1.577475e+000 -7.175042e+000 2.764545e-005 -5.966045e+000 1.451433e-005 -4.665347e+000 -1.412159e-005 6.154827e+000 0.000000e+000 0.000000e+000 3.100275e+002 0.000000e+000
2.500000e-003 4.346526e+000 -1.305610e+001 3.170804e-005 -5.790276e+000 1.632860e-005 -4.574010e+000 -1.459951e-005 6.069773e+000 -1.521847e+000 -1.521847e+000 3.009973e+002 0.000000e+000
5.000000e-003 1.055312e+001 -1.861278e+001 3.085889e-005 -5.604992e+000 1.797386e-005 -4.472427e+000 -1.651171e-005 5.977640e+000 -7.909049e+000 -7.909049e+000 3.029022e+002 0.000000e+000
7.500000e-003 1.676089e+001 -2.476250e+001 3.417608e-005 -5.412398e+000 2.195262e-005 -4.354189e+000 -1.823193e-005 5.874751e+000 -4.333744e+000 -4.333744e+000 2.982168e+002 0.000000e+000
1.000000e-002 2.276874e+001 -3.064776e+001 3.607515e-005 -5.204357e+000 2.585798e-005 -4.212604e+000 -1.948774e-005 5.763049e+000 -9.444781e+000 -9.444781e+000 2.864735e+002 0.000000e+000
1.250000e-002 2.901897e+001 -3.670245e+001 3.681956e-005 -4.988488e+000 2.942617e-005 -4.048886e+000 -2.254946e-005 5.638561e+000 -1.512790e+001 -1.512790e+001 2.852074e+002 0.000000e+000
1.500000e-002 3.479634e+001 -4.301166e+001 4.146322e-005 -4.756663e+000 3.338716e-005 -3.862872e+000 -2.427187e-005 5.499905e+000 -1.618025e+001 -1.618025e+001 2.797585e+002 0.000000e+000
1.750000e-002 4.052957e+001 -4.899462e+001 4.416380e-005 -4.503088e+000 3.794105e-005 -3.651641e+000 -2.608256e-005 5.350786e+000 -2.219509e+001 -2.219509e+001 2.736614e+002 0.000000e+000
2.000000e-002 4.657926e+001 -5.503798e+001 4.764674e-005 -4.231202e+000 4.255615e-005 -3.413258e+000 -2.911828e-005 5.187315e+000 -2.519971e+001 -2.519971e+001 2.689015e+002 0.000000e+000
Am I missing something? How can I get the column numbers to be passed? Is there a workaround? Thanks a lot.

The variables ARG1 etc are string variables, and column work differently for string or integer variable. So you must explicitly cast the values given to column to integers:
inter(min,max,var,colx)=(min<=column(int(var))&&column(int(var))<=max?column(int(colx)):NaN)
plot ARG1 u (inter(ARG2,ARG3,ARG4,ARG5)):ARG6

Related

Turning a running total to a daily count

This feels like a basic high school math thing I've clearly forgotten. Anyhoo, I have data that looks like:
$Data << EOD
2020-08-09 4
2020-08-10 5
2020-08-11 6
2020-08-13 7
2020-08-14 8
EOD
set xdata time
set timefmt "%Y-%m-%d"
plot $Data u 1:2
Which looks like
Sidenote: Not sure why first value is not plotted... do you?
I just want to see the daily increments, like so:
$Data << EOD
2020-08-09 1
2020-08-10 1
2020-08-11 1
2020-08-13 1
2020-08-14 1
EOD
set xdata time
set timefmt "%Y-%m-%d"
plot $Data u 1:2
How do I get Gnuplot to just show the daily increments as I want, without editing the Data as I have done above? Any tips to link the points for readability would be greatly appreciated!
Edit: revised version after piecewise getting more information.
Plotting is like looping the data columns. In the code below x0 and y0 hold the previous values and x1 and y1 the current values. The daily change is (y1-y0) divided by (x1-x0) multiplied by 3600*24. Remember, in gnuplot date and time are handled internally in seconds passed from January, 1st 1970 00:00:00. Check help time/date. Also check help operations binary and serial evaluation.
Data: (Singapore.csv)
Singapore,2020-08-22 04:27:49,1.2833,103.8333,56216,27,53651,2538,Singapore,960.9009249543145,0.048029030880888
Singapore,2020-08-21 04:27:41,1.2833,103.8333,56099,27,53119,2953,Singapore,958.9010422123966,0.04812920016399579
Singapore,2020-08-20 04:27:43,1.2833,103.8333,56031,27,52810,3194,Singapore,957.7387172,0.04818761042994057
Singapore,2020-08-18 04:27:56,1.2833,103.8333,55838,27,52350,3461,Singapore,954.4397653265801,0.048354167412872955
Singapore,2020-08-17 04:27:20,1.2833,103.8333,55747,27,51953,3767,Singapore,952.884300971755,0.048433099538988646
Singapore,2020-08-16 04:27:42,1.2833,103.8333,55661,27,51521,4113,Singapore,951.414301691371,0.04850793194516807
Singapore,2020-08-15 04:27:31,1.2833,103.8333,55580,27,51049,4504,Singapore,950.0297674854277,0.04857862540482188
Singapore,2020-08-14 04:51:19,1.2833,103.8333,55497,27,50736,4734,Singapore,948.6110472497082,0.04865127844748365
Singapore,2020-08-13 04:29:15,1.2833,103.8333,55395,27,50520,4848,Singapore,946.8675597311133,0.048740861088545896
Singapore,2020-08-12 04:27:29,1.2833,103.8333,55353,27,50128,5198,Singapore,946.1496531058093,0.048777844019294345
Singapore,2020-08-11 04:35:08,1.2833,103.8333,55292,27,49609,5656,Singapore,945.10697919763,0.04883165738262316
Singapore,2020-08-10 04:34:55,1.2833,103.8333,55104,27,48915,6162,Singapore,941.8934923986508,0.048998257839721254
Singapore,2020-08-09 04:34:54,1.2833,103.8333,54929,27,48583,6319,Singapore,938.9022147932179,0.04915436290484079
Singapore,2020-08-08 04:34:53,1.2833,103.8333,54797,27,48312,6458,Singapore,936.6459368279776,0.04927277040713908
Singapore,2020-08-07 04:35:11,1.2833,103.8333,54555,27,48031,6497,Singapore,932.5094272250363,0.04949133901567226
Singapore,2020-08-06 04:35:02,1.2833,103.8333,54254,27,47768,6459,Singapore,927.364429743692,0.049765915877170344
Singapore,2020-08-05 04:34:43,1.2833,103.8333,53346,27,47454,5865,Singapore,911.8439722252184,0.05061297941738837
Singapore,2020-08-04 04:41:59,1.2833,103.8333,53051,27,47179,5845,Singapore,906.8015328332033,0.050894422348306344
Singapore,2020-08-03 04:34:35,1.2833,103.8333,52825,27,46926,5872,Singapore,902.9385114684727,0.05111216280170374
Singapore,2020-08-02 04:34:47,1.2833,103.8333,52512,27,46740,5745,Singapore,897.5883978084703,0.05141681901279708
Singapore,2020-08-01 04:36:27,1.2833,103.8333,52205,27,46491,5687,Singapore,892.3408422377969,0.051719183986208214
Singapore,2020-07-31 04:35:18,1.2833,103.8333,51809,27,46308,5474,Singapore,885.572008342075,0.05211449748113262
Singapore,2020-07-30 04:35:05,1.2833,103.8333,51531,27,46098,5406,Singapore,880.8201502031592,0.052395645339698434
Singapore,2020-07-29 04:35:11,1.2833,103.8333,51197,27,45893,5277,Singapore,875.1110832305046,0.05273746508584488
Singapore,2020-07-28 04:58:43,1.2833,103.8333,50838,27,45692,5119,Singapore,868.9746908856455,0.05310987843738935
Singapore,2020-07-27 04:35:02,1.2833,103.8333,50369,27,45521,4821,Singapore,860.958066903086,0.05360439953145784
Singapore,2020-07-26 04:35:00,1.2833,103.8333,49888,27,45352,4509,Singapore,852.736326741868,0.05412123155869147
Singapore,2020-07-25 04:47:39,1.2833,103.8333,49375,27,45172,4176,Singapore,843.967610104228,0.05468354430379747
Singapore,2020-07-24 05:30:40,1.2833,103.8333,49098,27,45015,4056,Singapore,839.2328449802002,0.05499205670292069
Singapore,2020-07-23 05:15:04,1.2833,103.8333,48744,27,44795,3922,Singapore,833.1819177097823,0.055391432791728215
Singapore,2020-07-22 04:34:42,1.2833,103.8333,48434,27,44584,3823,Singapore,827.8830830944443,0.055745963579303795
Singapore,2020-07-21 04:38:46,1.2833,103.8333,48035,27,44371,3637,Singapore,821.0629701540578,0.0562090142604351
Singapore,2020-07-20 05:34:40,1.2833,103.8333,47912,27,44086,3799,Singapore,818.9605293228108,0.056353314409751214
Singapore,2020-07-19 04:34:58,1.2833,103.8333,47655,27,43833,3795,Singapore,814.5676244965466,0.056657223796033995
Singapore,2020-07-18 04:34:45,1.2833,103.8333,47453,27,43577,3849,Singapore,811.1148354891327,0.05689840473731903
Singapore,2020-07-17 04:34:50,1.2833,103.8333,47126,27,43256,3843,Singapore,805.5254196206959,0.057293213937104785
Singapore,2020-07-16 04:44:59,1.2833,103.8333,46878,27,42988,3863,Singapore,801.2863519284253,0.0575963138359145
Singapore,2020-07-15 04:34:39,1.2833,103.8333,46630,27,42737,3866,Singapore,797.0472842361551,0.05790263778683251
Singapore,2020-07-14 04:34:46,1.2833,103.8333,46283,26,42541,3716,Singapore,791.1160080699542,0.05617613378562323
Singapore,2020-07-13 04:43:04,1.2833,103.8333,45961,26,42285,3650,Singapore,785.6120572759579,0.05656970039816366
Singapore,2020-07-12 04:34:30,1.2833,103.8333,45783,26,42026,3731,Singapore,782.5695006258608,0.056789638075268115
Singapore,2020-07-11 04:34:26,1.2833,103.8333,45614,26,41780,3808,Singapore,779.6807811097573,0.05700004384618757
Singapore,2020-07-10 04:34:24,1.2833,103.8333,45423,26,41645,3752,Singapore,776.4160152661134,0.057239724368711886
Singapore,2020-07-09 04:34:23,1.2833,103.8333,45298,26,41323,3949,Singapore,774.2793884050902,0.05739767760166012
Singapore,2020-07-08 05:33:48,1.2833,103.8333,45140,26,41002,4112,Singapore,771.5786920527565,0.057598582188746125
Singapore,2020-07-07 04:34:00,1.2833,103.8333,44983,26,40717,4240,Singapore,768.8950887153113,0.05779961318720406
Singapore,2020-07-06 04:33:57,1.2833,103.8333,44800,26,40441,4333,Singapore,765.7670669907733,0.05803571428571429
Singapore,2020-07-05 04:33:46,1.2833,103.8333,44664,26,40117,4521,Singapore,763.4424169659796,0.05821243059287121
Singapore,2020-07-04 04:33:51,1.2833,103.8333,44479,26,39769,4684,Singapore,760.280209211665,0.058454551586141774
Singapore,2020-07-03 04:33:54,1.2833,103.8333,44310,26,39429,4855,Singapore,757.3914896955614,0.05867749943579328
Singapore,2020-07-02 04:33:46,1.2833,103.8333,44122,26,39011,5085,Singapore,754.1780028965823,0.05892751915144372
Singapore,2020-07-01 04:33:52,1.2833,103.8333,43907,26,38500,5381,Singapore,750.5030046956222,0.05921607033047122
Singapore,2020-06-30 04:33:48,1.2833,103.8333,43661,26,37985,5650,Singapore,746.298123033128,0.05954971256
Singapore,2020-06-29 04:33:44,1.2833,103.8333,43459,26,37508,5925,Singapore,742.8453340257144,0.05982650314089141
Singapore,2020-06-28 04:34:04,1.2833,103.8333,43246,26,37163,6057,Singapore,739.2045218545305,0.06012116727558618
Singapore,2020-06-27 04:33:35,1.2833,103.8333,42955,26,36825,6104,Singapore,734.2304545220682,0.06052846001629612
Singapore,2020-06-26 04:33:43,1.2833,103.8333,42736,26,36604,6106,Singapore,730.4870842615553,0.0608386372145264
Singapore,2020-06-25 05:26:54,1.2833,103.8333,42623,26,36299,6298,Singapore,728.5555735791902,0.060999929615465825
Singapore,2020-06-24 04:33:28,1.2833,103.8333,42432,26,35995,6411,Singapore,725.2908077355464,0.061274509803921566
Singapore,2020-06-23 04:33:22,1.2833,103.8333,42313,26,35590,6697,Singapore,723.2567389638522,0.06144683666958145
Singapore,2020-06-22 04:33:20,1.2833,103.8333,42095,26,34942,7127,Singapore,719.5304617182275,0.06176505523221285
Singapore,2020-06-21 04:33:19,1.2833,103.8333,41833,26,34224,7583,Singapore,715.0520918175225,0.06215188965649129
Singapore,2020-06-20 04:33:19,1.2833,103.8333,41615,26,33459,8130,Singapore,711.3258145718977,0.06247747206536105
Singapore,2020-06-19 04:33:17,1.2833,103.8333,41473,26,32712,8735,Singapore,708.8986064577753,0.06269138957876208
Singapore,2020-06-18 04:33:18,1.2833,103.8333,41216,26,31938,9252,Singapore,704.5057016315112,0.06308229813664597
Singapore,2020-06-17 04:33:21,1.2833,103.8333,40969,26,31163,9780,Singapore,700.2837269541291,0.06346261807708267
Singapore,2020-06-16 04:33:09,1.2833,103.8333,40818,26,30366,10426,Singapore,697.7026817060128,0.06369738840707531
Singapore,2020-06-15 03:33:14,1.2833,103.8333,40604,26,29589,10989,Singapore,694.0447765199408,0.06403310018717367
Singapore,2020-06-14 03:33:15,1.2833,103.8333,40197,26,28808,11363,Singapore,687.0879194604487,0.06468144388884743
Singapore,2020-06-13 03:33:14,1.2833,103.8333,39850,25,28040,11785,Singapore,681.1566432942478,0.06273525721455459
Singapore,2020-06-12 05:09:52,1.2833,103.8333,39387,25,27286,12076,Singapore,673.2425774010173,0.06347271942519106
Singapore,2020-06-11 03:33:41,1.2833,103.8333,38965,25,26532,12408,Singapore,666.0293251182025,0.06416014371872193
Singapore,2020-06-10 04:07:00,1.2833,103.8333,38514,25,25877,12612,Singapore,658.3203754036302,0.06491146076751311
Singapore,2020-06-09 03:33:03,1.2833,103.8333,38296,25,25368,12903,Singapore,654.5940981580054,0.06528096929183204
Singapore,2020-06-08 03:33:22,1.2833,103.8333,37910,25,24886,12999,Singapore,647.9961944111653,0.06594566077552097
Singapore,2020-06-07 03:53:30,1.2833,103.8333,37527,25,24559,12943,Singapore,641.4495697089897,0.06661870120180137
Singapore,2020-06-06 02:33:00,1.2833,103.8333,37183,24,24209,12950,Singapore,635.5695725874534,0.06454562568915903
Singapore,2020-06-05 02:33:06,1.2833,103.8333,36922,24,23904,12994,Singapore,631.1082957016366,0.06500189588863009
Singapore,2020-06-04 02:33:14,1.2833,103.8333,36405,24,23582,12799,Singapore,622.271207004444,0.06592501030078286
Singapore,2020-06-03 02:33:13,1.2833,103.8333,35836,24,23175,12637,Singapore,612.5452815330657,0.06697176024109834
Singapore,2020-06-02 02:33:08,1.2833,103.8333,35292,24,22466,12802,Singapore,603.246681433892,0.06800408024481469
Singapore,2020-06-01 02:32:46,1.2833,103.8333,34884,23,21699,13162,Singapore,596.2727313595118,0.06593280587088636
Singapore,2020-05-31 02:32:45,1.2833,103.8333,34366,23,20727,13616,Singapore,587.418549647431,0.06692661351335623
Singapore,2020-05-30 02:32:48,1.2833,103.8333,33860,23,19631,14206,Singapore,578.7694841140084,0.06792675723567632
Singapore,2020-05-29 02:32:50,1.2833,103.8333,33249,23,18294,14932,Singapore
Singapore,2020-05-28 02:32:31,1.2833,103.8333,32876,23,17276,15577,Singapore
Singapore,2020-05-27 02:32:31,1.2833,103.8333,32343,23,16444,15876,Singapore
Singapore,2020-05-26 02:32:35,1.2833,103.8333,31960,23,15738,16199,Singapore
Singapore,2020-05-25 02:32:44,1.2833,103.8333,31616,23,14876,16717,Singapore
Singapore,2020-05-24 02:32:43,1.2833,103.8333,31068,23,13882,17163,Singapore
Singapore,2020-05-23 02:32:42,1.2833,103.8333,30426,23,12995,17408,Singapore
Singapore,2020-05-22 02:36:51,1.2833,103.8333,29812,23,12117,17672,Singapore
Singapore,2020-05-21 02:32:48,1.2833,103.8333,29364,22,11207,18135,Singapore
Singapore,2020-05-20 02:32:19,1.2833,103.8333,28794,22,10365,18407,Singapore
Singapore,2020-05-19 02:32:18,1.2833,103.8333,28343,22,9835,18486,Singapore
Singapore,2020-05-18 02:32:21,1.2833,103.8333,28038,22,9340,18676,Singapore
Singapore,2020-05-17 02:32:32,1.2833,103.8333,27356,22,8342,18992,Singapore
Singapore,2020-05-16 02:32:19,1.2833,103.8333,26891,21,7248,19622,Singapore
Singapore,2020-05-15 02:33:02,1.2833,103.8333,26098,21,5973,20104,Singapore
Singapore,2020-05-14 03:32:28,1.2833,103.8333,25346,21,4809,20516,Singapore
Singapore,2020-05-13 03:32:26,1.2833,103.8333,24671,21,3851,20799,Singapore
Singapore,2020-05-12 03:32:27,1.2833,103.8333,23822,21,3225,20576,Singapore
Singapore,2020-05-11 02:32:30,1.2833,103.8333,23336,20,2721,20595,Singapore
Singapore,2020-05-10 02:32:30,1.2833,103.8333,22460,20,2296,20144,Singapore
Singapore,2020-05-09 02:32:35,1.2833,103.8333,21707,20,2040,19647,Singapore
Singapore,2020-05-08 02:32:32,1.2833,103.8333,20939,20,1712,19207,Singapore
Singapore,2020-05-07 02:32:28,1.2833,103.8333,20198,20,1634,18544,Singapore
Singapore,2020-05-06 02:32:31,1.2833,103.8333,19410,18,1519,17873,Singapore
Singapore,2020-05-05 02:32:34,1.2833,103.8333,18778,18,1457,17303,Singapore
Singapore,2020-05-04 02:32:28,1.2833,103.8333,18205,18,1408,16779,Singapore
Singapore,2020-05-03 02:32:28,1.2833,103.8333,17548,17,1347,16184,Singapore
Singapore,2020-05-02 02:32:27,1.2833,103.8333,17101,16,1268,15817,Singapore
Singapore,2020-05-01 02:32:28,1.2833,103.8333,16169,15,1244,14910,Singapore
Singapore,2020-04-30 02:32:27,1.2833,103.8333,15641,14,1188,14439,Singapore
Singapore,2020-04-29 02:32:29,1.2833,103.8333,14951,14,1128,13809,Singapore
Singapore,2020-04-28 02:30:32,1.2833,103.8333,14423,14,1095,13314,Singapore
Singapore,2020-04-27 02:30:33,1.2833,103.8333,13624,12,1060,12552,Singapore
Singapore,2020-04-26 02:30:31,1.2833,103.8333,12693,12,1002,11679,Singapore
Singapore,2020-04-25 06:30:33,1.2833,103.8333,12075,12,956,11107,Singapore
Singapore,2020-04-24 03:30:31,1.2833,103.8333,11178,12,924,10242,Singapore
Singapore,2020-04-22 23:30:32,1.2833,103.8333,10141,12,896,9233,Singapore
Singapore,2020-04-21 23:30:30,1.2833,103.8333,9125,11,839,8275,Singapore
Singapore,2020-04-20 23:36:27,1.2833,103.8333,8014,11,801,7202,Singapore
Singapore,2020-04-19 23:40:41,1.2833,103.8333,6588,11,768,5809,Singapore
Singapore,2020-04-18 22:32:28,1.2833,103.8333,5992,11,740,5241,Singapore
Singapore,2020-04-17 23:30:32,1.2833,103.8333,5050,11,708,4331,Singapore
Singapore,2020-04-16 23:30:31,1.2833,103.8333,4427,10,683,3734,Singapore
Singapore,2020-04-15 22:56:32,1.2833,103.8333,3699,10,652,3037,Singapore
Singapore,2020-04-14 23:33:12,1.2833,103.8333,3252,10,611,2631,Singapore
Singapore,2020-04-13 23:07:34,1.2833,103.8333,2918,9,586,2323,Singapore
Singapore,2020-04-12 23:17:00,1.2833,103.8333,2532,8,560,1964,Singapore
Singapore,2020-04-11 22:45:13,1.2833,103.8333,2299,8,528,1763,Singapore
Singapore,2020-04-10 22:53:48,1.2833,103.8333,2108,7,492,1609,Singapore
Singapore,2020-04-09 23:02:19,1.2833,103.8333,1910,6,460,1444,Singapore
Singapore,2020-04-08 22:51:39,1.2833,103.8333,1623,6,406,1211,Singapore
Singapore,2020-04-07 23:04:29,1.2833,103.8333,1481,6,377,1098,Singapore
Singapore,2020-04-05 23:06:26,1.2833,103.8333,1309,6,320,983,Singapore
Singapore,2020-04-03 22:46:20,1.2833,103.8333,1114,5,282,827,Singapore
Singapore,2020-04-01 21:58:34,1.2833,103.8333,1000,3,245,752,Singapore
Singapore,2020-03-31 23:43:43,1.2833,103.8333,926,3,240,683,Singapore
Singapore,2020-03-27 23:23:03,1.2833,103.8333,732,2,183,547,Singapore
Singapore,2020-03-26 23:48:18,1.2833,103.8333,683,2,172,509,Singapore
Singapore,2020-03-25 23:33:04,1.2833,103.8333,631,2,160,469,Singapore
Singapore,2020-03-24 23:37:15,1.2833,103.8333,558,2,156,400,Singapore
Singapore,2020-03-23 23:19:21,1.2833,103.8333,509,2,152,355,Singapore
Singapore,2020-03-21T13:13:30,432,2,140,1.3521,103.8198
Singapore,2020-03-20T15:43:24,385,0,124,1.3521,103.8198
Singapore,2020-03-19T16:13:36,345,0,114,1.3521,103.8198
Singapore,2020-03-18T13:33:12,313,0,114,1.3521,103.8198
Singapore,2020-03-17T15:33:06,266,0,114,1.3521,103.8198
Singapore,2020-03-16T14:38:45,243,0,109,1.3521,103.8198
Singapore,2020-03-15T18:20:18,226,0,105,1.3521,103.8198
Singapore,2020-03-14T16:14:30,212,0,105,1.3521,103.8198
Singapore,2020-03-11T20:00:00,200,0,97,1.3521,103.8198
Singapore,2020-03-11T13:53:24,178,0,96,1.2833,103.8333
Singapore,2020-03-11T13:53:24,178,0,96,1.2833,103.8333
Singapore,2020-03-10T05:13:07,160,0,78,1.2833,103.8333
Singapore,2020-03-08T13:33:13,150,0,78,1.2833,103.8333
Singapore,2020-03-08T13:33:13,150,0,78,1.2833,103.8333
Singapore,2020-03-07T17:53:03,138,0,78,1.2833,103.8333
Singapore,2020-03-06T13:03:12,130,0,78,1.2833,103.8333
Singapore,2020-03-05T13:43:04,117,0,78,1.2833,103.8333
Singapore,2020-03-03T15:23:03,110,0,78,1.2833,103.8333
Singapore,2020-03-03T15:23:03,110,0,78,1.2833,103.8333
Singapore,2020-03-02T20:33:02,108,0,78,1.2833,103.8333
Singapore,2020-03-01T23:23:02,106,0,72,1.2833,103.8333
Singapore,2020-02-29T14:33:03,102,0,72
Singapore,2020-02-26T19:33:02,93,0,62
Singapore,2020-02-26T19:33:02,93,0,62
Singapore,2020-02-26T19:33:02,93,0,62
Singapore,2020-02-25T18:55:32,91,0,53
Singapore,2020-02-23T15:13:15,89,0,51
Singapore,2020-02-23T15:13:15,89,0,51
Singapore,2020-02-21T03:43:02,85,0,37
Singapore,2020-02-21T03:43:02,85,0,37
Singapore,2020-02-19T22:13:08,84,0,34
Singapore,2020-02-19T22:13:08,84,0,34
Singapore,2020-02-18T16:53:03,81,0,29
Singapore,2020-02-17T14:33:04,77,0,24
Singapore,2020-02-16T16:23:06,75,0,18
Singapore,2020-02-15T23:53:02,72,0,18
Singapore,2020-02-14T12:43:02,67,0,17
Singapore,2020-02-13T14:33:02,58,0,15
Singapore,2020-02-12T19:53:02,50,0,15
Singapore,2020-02-11T16:43:06,47,0,9
Singapore,2020-02-10T19:03:02,45,0,2
Singapore,2020-02-09T02:43:02,40,0,2
Singapore,2020-02-08T12:53:01,33,0,2
Singapore,2020-02-07T03:03:03,30,0,0
Singapore,2020-02-05T16:33:03,28,0,0
Singapore,2020-02-05T16:33:03,28,0,0
Singapore,2020-02-04T15:33:03,24,0,0
Singapore,2020-02-02T01:03:32,18,0,0
Singapore,2020-02-02T01:03:32,18,0,0
Be aware that your date format changes within your file. But here it is not critical.
Singapore,2020-08-22 04:27:49,1.2833,103.8333,56216,27,53651,2538,Singapore,960.9009249543145,0.048029030880888
...
Singapore,2020-02-05T16:33:03,28,0,0
Code:
### plot daily change
reset session
FILE = "Singapore.csv"
set datafile separator comma
set format x "%m/%d" timedate
x1=NaN
y1=NaN
plot FILE u (x0=x1,x1=timecolumn(2,"%Y-%m-%d")):(y0=y1,y1=$5,(y1-y0)/(x1-x0)*3600*24) \
w lp pt 7 title "Daily change"
### end of code
Result:

Plotting a column of precision floating point values

I have a sequence of data that I have modified to the following:
load 'tables/csv'
load 'graphics/plot'
x =: readcsv 'table_ctl.csv'
dat =: 4 {::|:x
dat
The data in question is pulling the fourth column, that has been transposed of the following sequence of the array. Below is a sample of the first five values for the column.
13.5598 13.6815 14.027 14.132 14.0104
However upon running:
plot dat
I get the following error:
|option not found: 13.5598: signal
| signal'option not found: ',j
Is this error due to the precision of the floating point values?
Thank you.
You're getting this error as you're passing a list of boxes to plot, and plot is expecting some of these boxes to contain the data to plot, and some other boxes to contain control data. 13.5598 is not a valid option for a plot.
fread 'table_ctl.csv'
a,b,0,1,13.5598
a,b,0,1,13.6815
a,b,0,1,14.027
a,b,0,1,14.132
a,b,0,1,14.0104
4 {::|: readcsv 'table_ctl.csv'
┌───────┬───────┬──────┬──────┬───────┐
│13.5598│13.6815│14.027│14.132│14.0104│
└───────┴───────┴──────┴──────┴───────┘
Probably you were thinking that {:: automatically unboxes, but it only does this if the path you give it designates a single box. See the top text at Fetch. The other problem to have is that the contents of these boxes are strings, not floats:
$ > 4 {::|: readcsv 'table_ctl.csv'
5 7
|."1 > 4 {::|: readcsv 'table_ctl.csv'
8955.31
5186.31
720.41
231.41
4010.41
So, to plot your numbers: plot > makenum 4 {::|: readcsv 'table_ctl.csv' which starts with the list of boxes, then turns each box into a box of a float, then unboxes the list and plots it. makenum comes with readcsv and is like a smart ". each in this case, as it would leave non-numeric boxes alone.
There's a bit more to set up, but jd might also work for this:
fread 'table_ctl.cdefs'
1 label byte 1
2 name varbyte
3 enabled boolean
4 weight int
5 score float
options , LF NO \ 0 iso8601-char
load 'data/jd'
!!! Jd key: non-commercial use only!
jdwelcome_jd_ NB. run this sentence for important information
jdadminnew'temp'
CSVFOLDER=:'/path/to/csv/directory'
jd'csvrd table_ctl.csv data'
jd'info schema'
┌─────┬───────┬───────┬─────┐
│table│column │type │shape│
├─────┼───────┼───────┼─────┤
│data │label │byte │1 │
│data │name │varbyte│_ │
│data │enabled│boolean│_ │
│data │weight │int │_ │
│data │score │float │_ │
└─────┴───────┴───────┴─────┘
jd'get data score'
13.5598 13.6815 14.027 14.132 14.0104

How to apply tail command in gnuplot

I am defining my two colum data file as below in gnuplot file, plot.gnu.
FILE2='case.out'
I want to store the last value of second colum of case.out as Max. I tried as
Max =`(tail -n 2 FILE2 | awk '{print $2}')`
But it gives gives me error
Max =
^
"plot.gnu", line 37: constant expression required
But if I define exact name of file, case.out, instead writing FILE2 in Max command then it works well.
My case.out is something line
3.2853 243.4008
3.2936 243.6239
3.3019 243.8089
3.3103 243.9544
3.3186 244.0590
3.3269 244.1221
3.3353 244.1432
and I want the the Max command should store 244.1432 value.
i.e
print Max
should give 244.1432
Have a look into the manual and or in the gnuplot console type help stats. No need for awk here.
Code:
stats "case.out" u 2 nooutput
print STATS_max
Result:
244.1432
Addition:
Please check the manual about how stats works.
Code:
stats "case.out" u 1:2 nooutput
print STATS_min_x, STATS_max_x
print STATS_min_y, STATS_max_y
Result:
3.2853 3.3353
243.4008 244.1432
Or you can even "rename" the stats results.
Code:
stats "case1.out" u 1:2 nooutput name "First"
print First_min_x, First_max_x
print First_min_y, First_max_y
stats "case2.out" u 1:2 nooutput name "Second"
print Second_min_x, Second_max_x
print Second_min_y, Second_max_y

How to draw a horizontal line at the large y-axis integer?

For the following data.dat file:
08:01:59 451206975237005878
08:04:07 451207335040839108
08:05:56 451207643872368805
08:07:49 451207961547842270
08:09:56 451208317883903787
08:10:12 451208364811411904
08:14:09 451209030026853864
08:16:19 451209395116787156
08:17:14 451209552481002386
08:20:22 451210080432357203
08:25:36 451210963309583903
08:30:23 451211772783766177
08:34:04 451212394854723707
08:35:53 451212702239472024
08:48:46 451214876715294857
08:49:56 451215072475511660
08:51:24 451215321890488523
08:52:39 451215533925588479
08:52:42 451215542324801784
08:54:30 451215845971562410
08:55:08 451215951262906948
08:58:30 451216519498960432
I'd like to draw a horizontal line at the specific level (e.g. 451211772783766177). However, the number is too large to process.
Here is my attempt (based on this post):
$ gnuplot -p -e 'set arrow from 451211772783766177 to 451211772783766177; plot "data.dat" using 2 with lines'
which gives the following error:
line 0: warning: integer overflow; changing to floating point
How I should proceed?
I would treat your large number as a constant function, and plot it right after your data. Also, writing it on a exponential notation X.XE+YY = X.X times 10 to the +YY power (more info on format specifiers here) also takes care of the error:
plot "data.dat" using 2 with lines, 4.51211772783766177E17 with lines
Let me know if this works!

How to fix ';' expected error in gnuplot

I am using ubuntu 14.04, gnuplot 4.6 patchlevel 4.
I have the following script, named Plot.script:
## GNUPLOT command file
set terminal postscript color
set style data lines
set noxzeroaxis
set noyzeroaxis
set key top spacing .8
set size ratio 0.821894871074622
set noxtics
set noytics
set title 'Combined DET Plot'
set ylabel 'Miss probability (in %)'
set xlabel 'False Alarm probability (in %)'
set grid
set pointsize 3
set ytics (\
'5' -1.6449, '10' -1.2816, '20' -0.8416, '40' -0.2533, '60' 0.2533, \
'80' 0.8416, '90' 1.2816, '95' 1.6449, '98' 2.0537)
set xtics (\
'.0001' -4.7534, '.001' -4.2649, '.004' -3.9444, '.01' -3.7190, '.02' -3.5401, \
'.05' -3.2905, '.1' -3.0902, '.2' -2.8782, '.5' -2.5758, '1' -2.3263, \
'2' -2.0537, '5' -1.6449, '10' -1.2816, '20' -0.8416, '40' -0.2533)
plot [-4.75343910607888:-0.253347103317183] [-1.64485362793551:2.05374890849825] \
-x title 'Random Performance' with lines 1,\
'tmp/score.det.sub00.dat.1' using 3:2 title 'Term Wtd. fake : ALL Data Max Val=0.267 Scr=0.436' with lines 2,\
'tmp/score.det.sub00.dat.2' using 6:5 notitle with points 2,\
'tmp/score.det.sub01.dat.1' using 3:2 title 'Term Wtd. fake: CTS Subset Max Val=0.267 Scr=0.436' with lines 3,\
'tmp/score.det.sub01.dat.2' using 6:5 notitle with points 3
Then I run gnuplot Plot.script | ps2pdf - .
I get the following error:
line 27: ';' expected
line 27 is the last row of the script:
'tmp/score.det.sub01.dat.2' using 6:5 notitle with points 3
I have searched from web and found this similar question but it doesn't seem to help. Does anyone know what the problem is?
In general it is very hard to debug such a long script, especially without having the test data to run exactly this script. You should start by cutting down your script line by line to track down in which line the error really appears. The whole plot command is treated as a single line, so if it says line 27, the error can also appear earlier.
I guess, that you have the wrong syntax for selecting line types. Using with lines 1 doesn't work, and the simple line
plot x with lines 1
already shows this error. You must use
plot x with lines linetype 1
Accordingly you must fix all other positions where you set a line type (or point type).
line 27: ';' expected
can mean there's a ',' missing in the plot statement. I couldn't find it myself in your code. May be you need to delete blanks before "Scr="
But I had a similar problem.

Resources