gnuplot error: "Bad format character" despite "set datafile separator" - gnuplot

I'm non-native for English, so sorry for my poor English.
I use gnuplot 5.0.0 on MacOSX and execute next code.
plot "psd.dat" using 1:2
and the content of my psd.dat file is following:
-500 14.51 15.12
-450 14.54 15.08
-400 14.57 15.04
-350 14.59 15.02
-300 14.60 14.96
-250 14.66 14.95
-150 14.71 14.90
-100 14.76 14.87
-50 14.79 14.83
0 14.85 14.85
50 14.84 14.78
100 14.89 14.74
150 14.93 14.72
200 14.98 14.70
250 15.02 14.68
300 15.05 14.66
350 15.12 14.64
400 15.16 14.63
450 15.21 14.62
500 15.26 14.60
But I had next error.
Bad format character
I referred to gnuplot error: Bad format character | stackoverflow and execute:
set datafile separator whitespace
But even after I execute it, I also had "Bad format character" error.
I think what I did is very basic, so I have no idea why I had this error.
Do you have any idea to solve it? Please tell me.
P.S.
After I solve this error, I'd like to execute next code.
set autoscale fix
set format x "%d"
set format y "%.1f"
f(x) = a*x+b
a = 50000
b = 0
fit [-500:500] f(x) "psd.dat" using 1:(($2 - $3)/($2 + $3)) via a,b
plot "psd.dat" using 1:(($2 - $3)/($2 + $3)*a+b) w p, f(x)
set terminal tikz
set output "psd.tex"
replot
set terminal pdf
set output "psd.pdf"
replot
set terminal aqua

It has nothing to do with your data.
Gnuplot does not evaluate the format strings when you enter them (with set format), but only when the next plot is made.
"%d" is not a valid format string, so you get an error.

Related

Why gnuplot rounds data in column of vertical axis?

My old script worked fine years ago.
set terminal png background "#ffffff" enhanced fontscale 2.0 size 1800, 1400
set output 'delete.png'
w=1
x=1
z = 60
y=2
plot 'plot.in.tmp' using (column(x)/z):(column(y)) axis x1y1 with lines
exit gnuplot
reset
Now result in graph with only rounded integer points in y(vertical) axe. I dont understand why.
Example data in file:
0 -0,00 0,5 570,2 11,98 -0,121 0,000 9,6
5 -0,00 0,7 570,2 11,97 -0,002 0,012 13,2
10 -0,00 0,9 570,3 11,98 -0,004 -0,000 16,1
15 0,24 35,9 570,4 11,96 0,001 0,000 18,4
20 0,56 87,0 570,1 11,99 -0,001 -0,000 20,5
25 1,03 173,5 570,4 11,97 -0,000 0,000 23,2
30 1,61 296,4 570,3 11,96 0,002 0,000 12,4
35 2,17 422,6 570,2 11,68 0,004 0,000 8,8
40 2,81 571,6 570,2 11,37 0,010 0,001 7,5
45 3,52 752,3 570,3 11,26 0,015 0,000 7,1
50 3,97 905,0 570,2 11,69 0,075 0,006 7,4
55 4,36 1048,4 570,1 11,36 0,081 0,001 8,6
60 4,59 1156,8 570,2 11,22 0,087 0,001 10,7
Result graph:
Welcome to StackOverflow! Maybe the local setting of your system (or something in gnuplot) has changed?
The following works for me with your data.
Add a line
set decimalsign locale "german"
or
set decimalsign locale "french"
Check help decimalsign.
Syntax:
set decimalsign {<value> | locale {"<locale>"}}
Correct typesetting in most European countries requires:
set decimalsign ','
Please note: If you set an explicit string, this affects only numbers
that are printed using gnuplot's gprintf() formatting routine,
including axis tics. It does not affect the format expected for input
data, and it does not affect numbers printed with the sprintf()
formatting routine.
The answer given by theozh is correct, but it does not point out the unfortunate lack of standardization about how different operating systems report the current locale setting. For linux machines the locale strings are less human-friendly. For example instead of using something generic like "french", they subdivide into "fr_FR.UTF-8" "fr_BE.UTF-8" "fr_LU.UTF-8" etc to account for slight differences in the conventions used in France, Belgium, Luxembourg, etc.
I cannot tell you the exact set of locale descriptions on your machine, but here is what works for me on a linux machine:
set decimalsign locale "fr_FR.UTF-8"
w=1
x=1
z = 60
y=2
plot 'plot.in.tmp' using (column(x)/z):(column(y)) axis x1y1 with lines

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:

why only the first row of data was plotted [GNUPlot]

I have a data file data.txt, and data are as follows.
352 0.523240374 0.522909505 0.523471053
450 0.521095585 0.518197521 0.521120231
571 0.514979782 0.517518353 0.517105300
856 0.517216354 0.517600585 0.515035365
1259 0.514126520 0.514697120 0.514651830
2302 0.510628639 0.510990627 0.511418731
5276 0.507016704 0.507616124 0.505787979
And I wrote a gnuplot script plot.gpl, the code is
set term pdf enhanced font "Sans, 12"
set grid
set xlabel "Num of Cell"
set xrange [0:5500]
set ylabel "Numerical result"
set yrange [0.5:0.53]
set output "pic.pdf"
file = "data.txt"
plot file u 1:2 with linespoints ls 1 lw 0.1 ps 0.4 title "M11",\
file u 1:3 with linespoints ls 2 lw 0.1 ps 0.4 title "M22",\
file u 1:4 with linespoints ls 3 lw 0.1 ps 0.4 title "M33"
Then I typed the command gnuplot plot.gpl, a pdf file was generated, but only the first row of data.txt was plotted.
I tried to modify the format of data.txt, but failed.
Anyone can help me to solve this problem?
PS: Windows 10 Home, MSYS2: Mingw-w64 64 bit, gnuplot 5.2.0
For the sake of not letting this question appear unanswered. I guess according to SO "rules": no answers in comments.
Looks like you only have one line of data. Do you maybe have a text file which has been created on MacOS? Could you check your line end character? Is it \n (LF) (Linux) or \r\n (CR LF) (Windows) or \r (CR) (MacOs)? In the latter case you would get only the first row like you get.

How plot graph with missing data lines?

I have data recorded in time. But some data lines are missing and gnuplot replace them with long lines in these intervals.
How can i set gnuplot to draw nothing instead of draw lines in these intervals?
PS. I don't have free cells in these lines, I dont have these lines at all.
lines:
column 1 ... col 195
13:30:20.8 0.78061899
13:30:21.8 5.969546498
13:32:19.8 17.21257881
13:32:20.8 6.922475345
If you don't want to draw a line between two points you must insert an empty line in the data file between the two point entries, so that effectively you have
13:30:20.8 0.78061899
13:30:21.8 5.969546498
13:32:19.8 17.21257881
13:32:20.8 6.922475345
This cannot be done with gnuplot directly, but you can use e.g. awk to do the processing on-the-fly:
set timefmt '%H:%M:%S'
set xdata time
filename = 'data.txt'
plot 'awk ''{split($1,d,":"); t_prev = t; t = (d[1] * 60 + d[2])*60 + d[3]; if (t_prev && (t - t_prev > 10)) print ""; print }'' '.filename with lines
Here, the gap threshold is 10 seconds.
I suppose your miss data identifier is "NaN", then you can use the following command
plot "data" using 1:($2) with linespoints
instead of
plot "data" using 1:2 with linespoints
The former one will ignore the missing data and treat it as blank line and therefore not draw a connecting line across the gap while the latter one will draw continuous, unbroken line.
Just for the records: there are later questions about the same/similar issue.
Avoid connection of points when there is empty data
How to remove line between "jumping" values, in gnuplot?
Removing vertical lines due to sudden jumps in gnuplot
However, my solutions there require transparent color, which was not available in at the time of OP's question (gnuplot 4.6.5, Feb 2014). Nevertheless, there is a solution without external tools like awk or changing the data.
First solution for gnuplot 4.6.: Instead of a transparent line you use a white line which, however, will cover the grid lines, although it will be hardly visible.
Second solution for gnuplot 4.6 is using vectors. This really interrupts the line and will work for gnuplot 5.x as well.
Data:
00:00:00 0.406406
00:00:44 0.339779
00:01:28 0.986602
00:02:13 0.17746
00:02:57 0.0580277
00:03:42 0.586614
00:04:26 0.84247
00:05:11 0.597502
00:05:55 0.0394846
00:06:40 0.369416
00:13:20 0.527109
00:13:42 0.371411
00:14:04 0.851465
00:14:26 0.980312
00:14:48 0.431391
00:15:11 0.545491
00:15:33 0.708445
00:15:55 0.861669
00:16:17 0.277122
00:16:40 0.787273
Script:
### avoid showing a line across larger time gaps
reset
FILE = "SO26510245.dat"
myFmt = "%H:%M:%S"
tGap = 60 # 60 seconds
set format x "%H:%M"
set timefmt "%H:%M:%S"
set xdata time
set ytics 0.5
set key top center noautotitle
set grid x,y
set multiplot layout 3,1
plot FILE u 1:2 w l lc rgb "red" ti "data as is"
myColor(col) = (t0=t1, t1=timecolumn(1), t1-t0>tGap ? 0xffffff : 0x0000ff)
plot t1=NaN FILE u 1:2:(myColor(1)) w l lc rgb var ti "white line"
myGap(col) = (t1-t0>tGap ? NaN : y0)
plot t1=y1=NaN FILE u (t0=t1,t1=timecolumn(1),t0):(y0=y1,y1=$2,myGap(0)):(t1-t0):(y1-y0) \
w vec lc rgb "web-green" nohead ti "with vectors"
unset multiplot
### end of script
Result: (created with gnuplot 4.6.0, from March 2012)

GNUPlot add labels to scatterplot

I am making several graphs at once with a perl script which runs gnuplot and outputs png images.
My data looks like:
3.57 3.13 2.88 3.38 A1H1'-A1H8
4.95 4.53 4.17 4.89
3.91 3.37 3.11 3.64
3.98 4.22 3.88 4.55 A1H2'-A2H1'
...
columns are x, y, y low error, and point label.
GNUPlot input is:
set xlabel 'X-Ray Distance (Angstrom)'
set ylabel 'NOESY Distance (Angstrom)'
set title 'r(AAAA) A-Form Correlation'
set terminal png size 1200, 900
set xrange[2:9]
set yrange[2:9]
set output 'correlation_AAAA.png'
plot x title 'NMR = X-Ray', \
'correlation_AAAA.dat' title 'NMR' with yerrorbars
My question is, how can I get the 5th column to show as a label for some points (not all)?
This link: http://newsgroups.derkeiler.com/Archive/Comp/comp.graphics.apps.gnuplot/2008-02/msg00094.html says it is very difficult (nigh on impossible)
I got lost in all of the GNUPlot documentation. My own fault.
Here is the minimal working solution:
set label " A4H8-A3H3'" at 7.42, 2.98
set rmargin at screen 0.92
plot x title 'NMR = X-Ray', \
'correlation_AAAA.dat' title 'NMR' with yerrorbars
pause -1
the "set rmargin" is necessary so labels don't run off the screen edge.
Thanks for your kind help Christoph. I was confused when I tried to put "using labels with yerrorbars" which GNUPlot did not like.

Resources