Plotting with Gnuplot - BenningtonCS/Telescope-2014 GitHub Wiki
By now, you've parsed out either the spectra or the meta data or both from your original output file and you're ready to start plotting. You'll do this with the command line based gnuoplot, which is installed on the radiotelescope computer.
Procedure and General Tips
- Once you have your parsed .dat file, move it into the home directory of the radiotelescope machine. Gnuplot also lives in the home directory, so your parsed file must also be in the home directory so gnuplot can grab it.
- Run gnuplot by simply typing
$ gnuplotin the terminal. - Most of the following information was taken from this page, but I will reproduce some of it here for convenience.
- Let's say you know which meta data you want to plot against each other, or you know which spectra you want to plot. This data is organized into columns in the parsed file because gnuplot reads blocks of data in columns, so keep track of the column number that corresponds to the data you are concerned with.
- 2D plots are made using the
plotcommand. For example,gnuplot> plot sin(x)/xplots the function sin(x)/x. I recommend trying a few of these and getting the feel for simple plotting. - A more complex example that is closer to what you'll want is something like
gnuplot> plot 'SunSpectra.dat' using 1:6 title "Sample Sun Spectrum" with lines
where SunSpectra.dat is your parsed data file, using 1:6 means plotting data columns 1 on the x axis and 6 on the y axis, and with lines means connecting the points on the plot with lines.
- You can name your x and y axes with something like
gnuplot> set xlabel "Freq (MHz)"
gnuplot> set ylabel "PWR (K)"
- You can put a grid to your plot with the command
set grid. - Once you make changes to your plot, you must run the command
replotto apply your changes. - There is a lot gnuplot can do in the way of customizing and tweaking the aesthetics and functionality of your plot, so if you want to explore more on your own, please do! This is just the most basic operating info to use with the telescope data.
- Once you have made your plot and you want to save a photo file of it, you will want to run a set of commands like this:
gnuplot> set term postscript
gnuplot> set output "CrazySun.ps"
gnuplot> replot
gnuplot> set term x11
- The first command above changes the terminal (term) to making postscript files. The second command names your plot file. YOu must run the
replotcommand for you plot to actually get written to the postscript file you have just created. Then, set the terminal back to regular gnuplot with the last command. - You can do the same thing with PNG's, although I think the postcript files are nicer:
gnuplot> set term png
gnuplot> set output "CrazySun.png"
gnuplot> replot
gnuplot> set term x11
- After this series of commands, a png or postscript file of your plot will appear in the home directory of the radiotelescope machine.