Plotting data with gnuplot - Basic plot example
- Setting scale
set logscale x
unset logscale y
plot "datafile.txt"
- Setting range and grid
set xrange[100:10000]
set yrange[-10:20]
set grid
plot "datafile.txt"
- Plotting multiple data with title
plot "datafile.txt" using ($1):($2) title "Tc=-40deg",
"datafile.txt" using ($1):($2) title "Tc=85deg"
- Setting data style and grid then replot
set style data linespoints
rep
- Setting title and axis labels
set title "Gain V.S. Frequency"
set xlabel "frequency [MHz]
set ylabel "Gain [dB]"
rep
- Changing x axis format to engineering format (*note1)
set format x "%.1s%c"
set xlabel "frequency [Hz]
set xrange[100e6:10e9]
plot "datafile.txt" using ($1*1e6):($2) title "Tc=-40deg",
"datafile.txt" using ($1*1e6):($3) title "Tc=85deg"
- Adding x tics and labels
set xtics add (2.4e9)
set label 1 "Pin = -30 [dBm]" at 150e6, 7, 0 left
rep
- Smoothing data plot (*note1)
plot \
"datafile.txt" using ($1*1e6):($2) smooth bezier title "Tc=-40deg",\
"datafile.txt" using ($1*1e6):($3) smooth bezier title "Tc=85deg"
- set font for GIF output to Meiryo (*note3)
set terminal gif nocrop font "C:/WINDOWS/Fonts/meiryo.ttc ,9" size 360,240
set output "test-plot-font.gif"
rep
set output
note1: gnuplot version 3.5 (pre 3.6) patchlevel 325 beta or later requiered,
patchlevel 336 beta or later recommended.
note2: gnuplot home
note3: Meiryo font (of Microsoft Windows) or other font you wont to use should be installed at the path.



© 2000 Takayuki HOSODA.
Powered by