Howto: GNU Plot

I have two signals, x, xfilter stored on disk as signal.dat and filter.dat. For example xfilter is an MA(5).

Say x has 100 data points. Say xfilter has 95 data points. How do I tell GnuPlot to shift the plot to the right on the filter so that I can see one signal ontop of the other starting from the correct place?

The two signals are on disk in their corresponding text file, one column. I have figured out how to plot them just not translated correctly:

Code:
gnuplot> plot "signal.dat" title "Signal",\
              "filter.dat" title "Filter"

This works fine, but filter displays on the plot at the same place to the left as signal, which is wrong.

Is there a way to "pad" filter.dat with five (n) "empty" values so that gnuplot knows to leave those points blank? Or is this done with a command right from gnuplot?

Thanks!
 
I take it you aren't storing times in your files? If your file format was

<time> <signal value>

Then you could plot multiple signals like you want and they'd line up properly. The gnu plot for doing the plot would then look like

Plot "file1" using 1:2, "file2" using 1:2

Failing that, I'd have whatever script write the MA(n) file to write n zeros first.
 
Quote from MoreLeverage:

I take it you aren't storing times in your files? If your file format was

<time> <signal value>

Then you could plot multiple signals like you want and they'd line up properly. The gnu plot for doing the plot would then look like

Plot "file1" using 1:2, "file2" using 1:2

Failing that, I'd have whatever script write the MA(n) file to write n zeros first.

It would be very simple to label the points. But why with time stamps. Say I am using gnu plot to draw a sin wave and a cos wave that start at different x values? I will try it though starting the filter with label 5 and the signal with label 0.

Putting zeroes in front would make the left hand side jump suddenly from zero to value.
 
Quote from MoreLeverage:

I take it you aren't storing times in your files? If your file format was

<time> <signal value>

Then you could plot multiple signals like you want and they'd line up properly. The gnu plot for doing the plot would then look like

Plot "file1" using 1:2, "file2" using 1:2

Failing that, I'd have whatever script write the MA(n) file to write n zeros first.
MoreLeverage that worked. Simply labeling the points 1,2,3...N for signal and 5,6,7...N for filter and using 1:2 in the plot command did the trick. Everything lines up correctly on the left.

Thanks!
 
Back
Top