Plotting data with gnuplot - Basic plot example

datafile.txt : example data file

  1. Setting scale

    set logscale x
    unset logscale y
    plot "datafile.txt"

    semi logscale

  2. Setting range and grid

    set xrange[100:10000]
    set yrange[-10:20]
    set grid
    plot "datafile.txt"

    plot with grid

  3. Plotting multiple data with title

    plot "datafile.txt" using ($1):($2) title "Tc=-40deg", "datafile.txt" using ($1):($2) title "Tc=85deg"

    multipule data plot

  4. Setting data style and grid then replot

    set style data linespoints

    lines and points style

  5. Setting title and axis labels
    set title "Gain V.S. Frequency"
    set xlabel "frequency [MHz]
    set ylabel "Gain [dB]"

    lines and points style

  6. 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"

    engneering format

  7. Adding x tics and labels

    set xtics add (2.4e9)
    set label 1 "Pin = -30 [dBm]" at 150e6, 7, 0 left

    datafile.txt : example data file

  8. 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"

    datafile.txt : example data file

  9. 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"
    set output

    datafile.txt : example data file

gnuplot version 3.5 (pre 3.6) patchlevel 325 beta or later requiered,
patchlevel 336 beta or later recommended.

gnuplot home

Meiryo font (of Microsoft Windows) or other font you wont to use should be installed at the path. [Mail] © 2000 Takayuki HOSODA.
Powered by