Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Here is a simple script to plot FM radio station frequencies

4 views
Skip to first unread message

Håkon Løvdal

unread,
May 14, 2007, 5:17:09 PM5/14/07
to
Hi. A few days ago I asked how to plot just one axis (to which
Ethan A Merritt gave an excellent answer). I also found a lot of
useful information at the "not so Frequently Asked Questions" site
http://t16web.lanl.gov/Kawano/gnuplot/index-e.html.

I wanted to plot a line with marks for the frequencies to the FM radio
stations that I receive and here is the results of that. I assume other
might find this useful.

BR Håkon Løvdal


::::::::::::::
radiofrequencies.gnuplot
::::::::::::::

set terminal postscript eps colour
set output "radiofrequencies.eps"

set title "Radio frequencies"

set border 1 # only draw the lower x boundary
unset ytics # no ytics at all
set yrange [-1:1] # arbitrary, but it prevents an error msg
unset yzeroaxis # don't draw the axis itself
unset xzeroaxis # don't draw the axis itself
set xtics nomirror # xtics only on the bottom
set bmargin 5 # leave room at the bottom for labels
set rmargin 5 # leave some space at the right
set lmargin 5 # and left edges
unset key # no legend box

set size 1.0,0.6
set bmargin 0

set xrange [87:108]

set multiplot

set origin 0,0.4
set xtics 1 offset 0.0,2.0 # this line requires gnuplot 4.1 or higher
set xlabel "MHz" 0.0,5.0
plot 0 with dots linetype -3 # plot something invisible (white dots)

set origin 0,0.4
set xtics offset 0.0,0.0
set xtics textcolor rgb "red" font "Helvetica,8"
set xtics out rotate by -90

load "radiofrequencies.xtics"

unset xlabel
plot 0 with dots linetype -3 # plot something invisible (white dots)

set nomultiplot


::::::::::::::
Makefile
::::::::::::::

all: radiofrequencies.eps

radiofrequencies.eps: radiofrequencies.xtics

%.eps: %.gnuplot
gnuplot $^

%.xtics: %.txt
perl -w freq2xtics.pl $^ > $@

clean:
rm -f radiofrequencies.xtics radiofrequencies.eps


::::::::::::::
freq2xtics.pl
::::::::::::::

#!/usr/bin/perl -w
use strict;
use warnings;
my $locale_comma = 1;
my @all = ();
while (<>) {
chomp;
s/\s*#.*//; # ignore comments
next if /^$/; # skip blank lines
my ($freq, $name) = split(/\t/);
my $freq_str = $freq;
$freq_str =~ s/\./,/ if $locale_comma;
push @all, "\"$name\t$freq_str\" $freq";
}
print "set xtics (", join(", ", @all), ")\n";

::::::::::::::
radiofrequencies.txt
::::::::::::::

# freq name (separate with tabulator)

87.8 Radio station 1
88.3 Radio station 2
88.8 Radio station 1
# ...
105.50 Radio station N
106.50 Radio station N+1
106.90 Radio station N+2

0 new messages