GTK: Configuring gnuplot

Cogent Tools Demo and Tutorials: Version 4.0
Prev | Chapter 14. History Functions | Next

# 14.8. GTK: Configuring gnuplot

You can comprehend the data from a query more easily by plotting it with gnuplot, the Linux plotting program. We configure gnuplot for History using the `plhist.cfg` configuration file, which loads the `plmain.cfg` and `plhistsetup.dat` files.

The `plmain.cfg` file is a configuration file that holds commands that are common to plots for Log and History, like labels, borders, and data styles. It is shown and explained in the Configuring and Using gnuplot section of the Log chapter of this manual.

## `plhist.cfg`

    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    #DOCUMENT:      plhist.cfg
    #DEPENDENCIES:  plmain.cfg plhistsetup.dat
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    set title "Cascade Historian Output"

    load "plmain.cfg"
    load "/tmp/cogentdemo/plhistsetup.dat"

    # The xlab and histtime values come from plhistsetup.dat.
    # The xlab == 1 for "NoInterpolator" and "Periodic" interpolators.
    # The xlab == 2 for "Relative" and "FixedRelative" interpolators.
    # The histtime is the number of seconds after midnight.

    set ylabel "Y history" 1,0
    if (xlab == 1) set xlabel "Time (in seconds after midnight)" 0,0
    if (xlab == 2) set xlabel "X history" 0,0

    set xrange [x_min:x_max]
    set yrange [y_min:y_max]

    set data style linespoints
    set pointsize 1.5

    set multiplot

    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # "NoInterpolator" and "Periodic" interpolator options
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # Full data set (no deadband)
    #
    if ((xlab == 1) && (db1 == 1)) plot '/tmp/cogentdemo/hsoutputpl.dat' \
    index 0 using (column(1) - histtime):2 ls 12

    #
    # Deadband on, prior value off
    #
    if ((xlab == 1) && (db2 == 1)) plot '/tmp/cogentdemo/hsoutputpl.dat' \
    index 1 using (column(1) - histtime):2 ls 19

    #
    # Deadband on, prior value on
    #
    if ((xlab == 1) && (db3 == 1)) plot '/tmp/cogentdemo/hsoutputpl.dat' \
    index 2 using (column(1) - histtime):2 ls 18

    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # "Relative" and "FixedRelative" interpolator options
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # Full data set (no deadband)
    #
    if ((xlab == 2) && (db1 == 1))  plot '/tmp/cogentdemo/hsoutputpl.dat' \
    index 0 using 1:2 ls 12

    #
    # Deadband on, prior value off
    #
    if ((xlab == 2) && (db2 == 1))  plot '/tmp/cogentdemo/hsoutputpl.dat' \
    index 1 using 1:2 ls 19

    #
    # Deadband on, prior value on
    #
    if ((xlab == 2) && (db3 == 1))  plot '/tmp/cogentdemo/hsoutputpl.dat' \
    index 2 using 1:2 ls 18

    set nomultiplot

    # Pause for 1 second, then replot.  Continue until gnuplot is terminated.

    pause 1
    reread

## `plhistsetup.dat`

The `plhistsetup.dat` file is a data file that is written at run-time by the `show_data` and `plot_prep` functions. This file contains strings that declare the values of the variables used in `plhist.cfg`. This file changes each time new data is plotted, but a typical example is shown here.

        histtime = 1036990800
        xlab = 1
        db1 = 1
        db2 = 0
        db3 = 1
        x_min = 51365.253553032875061
        x_max = 51369.963547945022583
        y_min = 102
        y_max = 195

This file would configure the plot to have an X-axis label (`xlab`) of: Time (in seconds after midnight), with two plots showing the data selected with the Full data set (no deadband) button (`db1`) and the Deadband on, prior value on button (`db3`). The X-axis values would range from `51365.2` to `51369.9`, and the Y-axis values from `102` to `195`.

Prev | Home | Next
GTK: Displaying Query Data - `show_data`, `write_minmax`, `file_add` | Up | GTK: the Deadband Type Window - `create_dbtype_win`, `db_labels`, `db_options`

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.