value y error with gnuplot. I can't see it - gnuplot

I have these error in gnuplot code: "line 0: all points y value undefined!"
The conf is:
set datafile separator ","
set terminal png
set xdata time
set terminal png size 1024,768
set autoscale y
set output "kk.png"
set timefmt "%Y/%m/%d"
set xrange ["12/04/2015":"12/05/2015"]
plot './datos_2978.dat' using 1:2 title 'cpu' with line
And data:
12/04/15,28
27/04/15,25
05/05/15,17
11/05/15,16
Could you help me please? Thanks

Looks to me that your timefmt string is incorrect, you are setting "%Y/%m/%d", but the data is "%d/%m/%Y".
Furthermore you should define your xrange like this:
set xrange ["12/04/15":"12/05/15"]

I solved the problem. I missed set yrange[xxx:yyyy].

Related

Gnuplot for a simple date-time plot

For this datafile:
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
I would like a plot with column 7 on the y-axis and column 4 on the x-axis. I would like to make the x-axis go from Jan 21-2022 to Jan-25 2022. I would like the y-axis to be scaled so that 1 is 10^6.
The problems have to do (I think) with the parsing of the date.time and the scaling of the x axis.
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's set datafile separator comma and your set datafile separator ',' should be equivalent.
Two little details:
your time format should be %Y-%m-%dT%H:%M:%SZ not %Y-%m-%d:%H:%M:%SZ. Find the difference!
# at the beginning of a line makes it a comment. So, remove # in the line #set xdata time
By the way, you could also just enter set xrange ["2022-01-19":"2022-01-24"]. If gnuplot will not find hours, minuts, seconds, I guess it will assume them to be zero.
Check the following slightly modified code.
Code:
### 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
Result:

Gnuplot: how to set xrange with set xtics time?

I plot a time-series of datas (images, throughput), using this:
set term postscript color eps enhanced 22
set encoding utf8
set output "tput.eps"
load "../styles.inc"
set size 1,0.6
set bmargin 4.5
set tmargin 2.5
set lmargin 9
set rmargin 8
set title "{/bold Images updated and generated network traffic}" offset 0,0
set ylabel "#Images" offset 0,0
set y2label "Throughput [GB/day]" offset -2,0
set ytics 0,100,800
set ytics nomirror
set y2tics 0,100,600
set y2tics nomirror
set xtics time
set format x '%d/%m/%Y'
set grid y
set yrange[0:800]
set y2range [0:]
set xtics rotate by 45 right font "Arial, 18" nomirror
set key vertical sample 1.0 maxrows 1 width -0.6 at graph 1,1.13 font "Arial, 18"
set datafile separator ","
plot "datecount_sorted.csv" using (timecolumn(1, "%Y-%m-%d")):($2) with lines ls 5001 title "Uploaded images",\
"datecount_sorted.csv" using (timecolumn(1, "%Y-%m-%d")):($3/(1024*1024*1024)) axis x1y2 ls 5002 title "Upload Throughput",\
!epstopdf "tput.eps"
!rm "tput.eps"
quit
The input data looks like this:
2016-04-12,1,0
2016-05-02,2,0
2016-05-05,2,0
2016-05-06,1,0
2016-05-11,2,0
2016-05-13,3,0
2016-05-25,2,0
2016-06-01,3,541204241
2016-06-06,1,0
2016-06-13,1,471311979
2016-06-14,1,6329289
2016-06-17,1,137972881
2016-06-24,1,319050239
2016-06-27,1,138193384
The output is correct, it looks like this:
The problem is that when I try to set an xrange, the plot breaks completely (does not render).
This syntax in particular seems to be wrong:
set xrange ["2020-01-01":"2020-06-17"]
And similarly wrong is the one using the same timefmt that is used in the plot:
set xrange ["01/01/2020":"17/06/2020"]
So..what is the correct syntax ?
What you are missing is set xdata time and set timefmt <format string> to tell gnuplot how read the dates from the data, the xrange is set using the format specified in timefmt, which doesn't have to be the same as the format you give to the axis, the plot breaks because it can't decode the dates from the xrange.
In your case adding this should suffice
set xdata time
set timefmt "%Y/%m/%d"
I tested it with set xrange ["2016/04/12":"2016/05/03"] on the example data file you posted.
You must explicitely parse the time strings passed to the range settings:
set xtics time
FMT="%Y-%m-%d"
set format x "%d/%m/%Y"
set xrange [strptime(FMT, "2016-01-01"):strptime(FMT, "2016-06-17")]
set datafile separator commna
plot "datecount_sorted.csv" using (timecolumn(1, FMT)):2 with lines title "Uploaded images"

Gnuplot for loop output

I have two different text files which have a data column and a value column each. Ĩ wanted to plot both using a 'plot for' loop but I wanted to changed the name of the output to match the file I'm plotting. Right now my code looks like this:
set terminal postscript eps color
set out "test.eps"
set size 0.6
set multiplot
set xdata time
set timefmt "%Y-%m"
set format x "%b\n%y"
set xtics "2004-01", 12*2629746, "2016-12"
filenames = 'ArcheryData.txt CanyoningData.txt'
plot for [file in filenames] file u 1:2 w l title file
What I get now is the test.eps file which has the two data files plotted in the same graph.
In that case, you might use the do loop as:
set terminal postscript eps color
set size 0.6
set xdata time
set timefmt "%Y-%m"
set format x "%b\n%y"
set xtics "2004-01", 12*2629746, "2016-12"
do for [ name in "ArcheryData CanyoningData" ]{
set output name.".eps"
plot name.".txt" u 1:2 w l title name
}
Alternatively, the variable name could be specified when invoking Gnuplot, thus with a script as:
set terminal postscript eps color
set size 0.6
set xdata time
set timefmt "%Y-%m"
set format x "%b\n%y"
set xtics "2004-01", 12*2629746, "2016-12"
set output name.".eps"
plot name.".txt" u 1:2 w l title name
one might then use it as gnuplot -e "name='ArcheryData';" fig.gpl

All points y value undefined! in gnuplot

I'm getting this error:
line 0:all points y value undefined!
My code for gnuplot is:
set terminal png 8;
set output "skript01_31/image10.png";
set timefmt x "%Y-%m-%d %H:%M:%S";
set xdata time;
set format x "%H:%M";
set xlabel "Cas";
set ylabel "Hodnota";
set yrange [:];
set xrange ["2009-05-11 07:30:00":"2009-06-11 00:34:00"];
set title "skript01";
set grid;
plot 'skript01_31/gnuplot_file' using 1:3 with points pt 7 ps 1 title "./skript01.sh";
My data file:
[2009-05-11 07:30:00] 0
[2009-05-11 07:31:00] 0.00999983333416666468
[2009-05-11 07:32:00] 0.01999866669333307936
[2009-05-11 07:33:00] 0.02999550020249566076
[2009-05-11 07:34:00] 0.03998933418663415945
[2009-06-11 00:34:00] 0.05
What I'm doing wrong?
Thanks for answer.
For the time format, this should be set timefmt x "[%Y-%m-%d %H:%M:%S]";, with the addition of the square brackets to match the time format used in the data file. Additionally the xrange variable should also acquire additional square brackets to match: set xrange ["[2009-05-11 07:30:00]":"[2009-06-11 00:34:00]"];

Gnuplot, setting yrange days back

I have put up a raspberry pi to measure temperature and call a Gnuplot script to place a graph on a webpage.
Now i want to make a couple of graphs that display 1hour backwards in time/1day backwards in time.
Does anyone know how i specify the X-range to start at "current time - 1 day" or "current time - 1 hour"?
Thanx!
This won't work everywhere, but if your gnuplot supports pipes and your system has the date command ...
TIMEFMT = "%Y:%m:%d:%H:%M:%S"
#now = "`date +%Y:%m:%d:%H:%M:%S`" #Use this line in production
now = '2013:01:24:20:49:30' #Hard-code this for the sake of the example ...
now_secs = strptime(TIMEFMT,now)
one_hour_past = now_secs - 3600.0
set xdata time
#set timefmt TIMEFMT #This doesn't parse correctly ... Not sure why...
eval(sprintf('set timefmt "%s"',TIMEFMT))
print strftime(TIMEFMT,one_hour_past)
#set xrange [strftime(TIMEFMT,one_hour_past):] #This doesn't seem to work
#set xrange ["2013:01:24:20:49:30":] #This works, but is declared statically -- Yuck.
eval(sprintf('set xrange ["%s":]',strftime(TIMEFMT,one_hour_past)))
plot '-' u 1:2 w l
2013:01:24:10:00:00 2.5
2013:01:24:21:00:00 2
2013:01:24:22:00:00 3
e
THe code i have used is as follows. Im running it on a Raspberry Pi with Rasbian OS. Any sudgestions? Thanx!
#!/usr/bin/gnuplot
reset
set terminal png size 1250,700
set object 1 rectangle from screen 0,0 to screen 1,1 fillcolor rgb"#E6E6FA" behind
set output '/var/www/bild.png'
set multiplot
set xdata time
set timefmt "%Y-%m-%d %H:%M:%S"
set format x "%H:%M\n%d/%m"
set xlabel "Timme/datum"
set ylabel "Inomhustemperatur"
set yrange [15:28]
set y2label "Utomhustemperatur"
set y2range [-20:10]
set y2tics nomirror
set y2tics
set title "Temperatur"
set key reverse Left outside
set grid
set style data lines
plot "logg.txt" using 1:3 axes x1y1 lw 3 title "inomhus", "" using 1:4 axes x1y2 lw 3 title "utomhus"#

Resources