Date/Time Axes In gnuplot - date

I'm unable to get date/time to work in gnuplot. Here's what seems right to me, errors described below.
set xdata time
set timefmt "%Y-%j/%H:%M:%S"
#set xrange ["2016-349/00:56:00":"2016-349/00:57:00"]
set format x "%H:%M:%S"
plot "-" using ($1):($2) with lines
2016-349/00:56:26.560000 0.587785252292582
2016-349/00:56:27.560000 1.59702608337727e-13
2016-349/00:56:28.560000 -0.587785252292324
e
pause mouse any
With set xrange commented out as shown, I get this warning.
Warning: empty x range [2016:2016], adjusting to [1995.84:2036.16]
and the x-axis doesn't appear to be based on the range of the data, with ticks from 00:33:15 to 00:34:00. The resulting plot is a vertical line at 00:33:36, but the points are part of a sine wave.
Uncommenting set xrange, I get this error instead.
line 6: all points y value undefined!
I get the same behavior with gnuplot 4.2 patchlevel 6, and 5.0 patchlevel 1. Thanks for any help you can provide.
Jim

The error is here:
plot "-" using ($1):($2) with lines
You can use $ only in expressions, otherwise just use numbers itself:
plot "-" using 1:2 with lines

Related

Matlab date help on x-axis

I have a porkchop plot that looks similar to this:
The contour function used to make it has input arguments for the x and y positions that are serial dates (as that seemed to be required by MATLAB). Then I used the following command to get the format I want:
datetick('x', 2); datetick('y', 2);
The problem I am having is that when I zoom in on the plot the tick labels to not autogenerate and I can be left with no ticks on the x or y axis if I zoom in to use a weeks' date range for example.
I tried enabling 'auto' for XtickMode and YtickMode but when I zoom in or pan after using those commands the relationship between the independent and dependent variables are lost for some reason (aka the dates don't stay with data like they do when you just have numbers on the x axis and zoom in).
Any ideas on how to solve this issue to get the functionality I'm looking for?
I have also tried the command xtickformat('dd-MMM-yy') but I get an error "Invalid numeric tick label format." when I use it with the contour plot.
As far as I know there is no builtin method in MATLAB to do this. I use the datetickzoom function from the MATLAB FileExchange. If you replace all instances of datetick with datetickzoom, it will automatically update the relevant axis labels when you zoom in.

Line increment in gnuplot

I have large files (~5 Gbs) whit constant increment on x-axis, let's say each dt.
I would like to know if I could set the every command of Gnuplot as logarithmic increment not linear.
plot "fileA.txt" u 1:2 every dt #linear increment of dt
This is because, if x-axis is in log-scale, then I want to have more points for low values of x in (10^-4,10^-2) but also not an oversampling in (10^4,10^2) range. Somehow a differential increment.
Does I have to use external programs like sed to re-write my file first?
A test plot is included as well as the data. In blue the full data, in red the ones with the every command. As you can see one loose the information for short x also oversample the plot for large x. the data file
Many thanks.
You could plot smoothed data with points:
set key left
set logscale x
set yrange [3.9:4.8]
set samples 30
set terminal png
set output "log.png"
plot "fort.11" title "raw" with points lc 3 pointtype 5 pointsize 2,\
"" title "smooth" smooth csplines with points lc 1 pointtype 5 pointsize 1
set samples 30 tells gnuplot to use 30 points equidistant in x
smooth csplines interpolates the datapoints
with points plots with points instead of lines, which would be the default
Note that this does not plot the original data, and that smooth csplines introduces new points if the original datapoints are too far apart. This might or might not be what you want.

Line is not shown in the diagram using gnuplot

I am trying to plot a diagram using gnuplot. I want to put the hours of the day in the x-axis. I managed to do that with the following code:
set term postscript eps enhanced color "Times" 24
set output "DailyAvailability.eps"
set xtics rotate by -45 font ",18"
set xdata time
set timefmt '%Y-%m-%d %H'
set format x '%H:%M'
set ylabel "Number of peers"
set xlabel "Time of the day [in hours]"
set yrange [0:30]
set xrange ['2015-12-30 15:50':'2015-12-30 16:00']
set key right top #FFA500"
plot "intervals.dat" using 1:2 lc rgb "#000077" t "availability" w lines
This is my input data
"2015-12-30 15:59" 6
"2015-12-30 15:58" 10
"2015-12-30 15:57" 17
"2015-12-30 15:56" 18
"2015-12-30 15:55" 19
"2015-12-30 15:54" 20
"2015-12-30 15:53" 18
"2015-12-30 15:52" 28
"2015-12-30 15:51" 23
After executing the code, I get the diagram but with no line drawn in it. I tried to read other questions, but I cannot see any major differences between their code and mine Gnuplot date/time in x axis. I also checked for blank spaces in the input file, but since there is no error or warning messages, I cannot figure out what is going on. Can anybody see what I am missing here? Thanks for your time!
There are two tiny mistakes that make gnuplot say
Skipping data file with no valid points
Your time format is missing the minutes %M. Hence %H should be %H:%M
The quotation marks which are part of your time format are missing.
The solution is supposed to look like this
set timefmt '"%Y-%m-%d %H:%M"'
Then, I get

translate matlab plot to gnuplot 3d

I have a matrix of fft data over time, 8192 rows of data x 600 columns of time. The first column is a frequency label, the first row is shown below but doesn't actually exist in the data file, neither do the spaces, they are shown just for ease of reading.
Frequency, Sec1, Sec2, Sec3...Sec600
1e8, -95, -90, -92
1.1e8, -100, -101, -103
...
It is plotted in matlab with the following code (Apologies to other posters, I grabbed the wrong matlab code)
x is a matrix of 8192 rows by 600 columns, f is an array of frequency labels, FrameLength = 1, figN = 3
function [] = TimeFreq(x,f,FrameLength,figN)
[t,fftSize] = size(x);
t = (1:1:t) * FrameLength;
figure(figN);
mesh(f,t,x)
xlabel('Frequency, Hz')
ylabel('time, sec')
zlabel('Power, dBm')
title('Time-Freq Representation')
I cant quite figure out how to make it work in gnuplot. Here is a sample image of what it looks like in Matlab: http://imagebin.org/253633
To make this work in gnuplot, you'll want to take a look at the splot (for "surface plot") command. You can probably figure out quite a lot about it just by running the following commands in your terminal:
$ gnuplot
gnuplot> help splot
Specifically, you want to read the help page shown by running (after the above, when the prompt asks for a subtopic): datafile. That should tell you enough to get you started.
Also, the answers to this question might be helpful.
so here is the gnuplot command script that I ended up using. It has some additional elements in it that weren't in the original matlab plot but all the essentials are there.
set term png size 1900,1080
set datafile separator ","
set pm3d
# reverse our records so that time moves away from our perspective of the chart
set xrange[*:*] reverse
# hide parts of the chart that would make the 3d view look funny
set hidden3d
# slightly roate our perspective and compress the z axis
set view 45,75,,0.85
set palette defined (-120 "yellow", -70 "red", -30 "blue")
set grid x y z
set xlabel "time (secs)"
set ylabel "frequency"
set zlabel "dBm"
# plot all the data
set output waterfall.png
splot 'waterfall.csv' nonuniform matrix using 1:2:3 with pm3d lc palette

MATLAB - datetick (specify number of points on axis)

I use datetick('x','HH:MM:SS.FFF'). How can I specify how many labels (specially denotes points) on the x-axis it puts?
datetick replaces the labels of the current tick marks with formatted date/time strings.
You control the actual location of the ticks using axes properties
XTick, YTick, ZTick: vector of data values locating tick marks
set(gca,'xtick', [1 4 6]);%sets ticks at x=1, x=4, x=6
gca is "get current axes", so this will change the xtick locations on the most recent axes you've activated (created, clicked on, or however else). If you have a axes handle to another set of axes, you can use that handle in place of "gca".