Skip to main content
Engineering LibreTexts

25.2: Formatting Plot Files

  • Page ID
    54407
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Since our specific use of GNUplot will involve plotting a data file created with a Fortran program, it will be necessary to provide some information and directions for GNUplot in the file. That information is provided in a header (first few lines) and a footer (last few lines). As such, the program must first write the header, write the data, typically in the form of data points to be plotted, and write a final footer. The header and footer may be very different based on what is being plotted.

    Header

    The header will provides some guidelines on how the output should look, including title (if any), axises (if any), labels (if any), and plotting color(s). Additionally, comments can be included with a “#” character. Comments are useful to provide information about the contents of the plot file or nature of the data being plotted. A typical header might be as follows:

    # Example Plot File
    set title "CS 117 Plot Function"
    plot "-" notitle with dots linewidth 2 linecolor 2
    

    Once the header is written, a series of data points can be written.

    Footer

    The footer is used to formally tell GNUplot there are no more points. Additionally, the “pause” directive can be used to ensure that any plots displayed from the command line are left on the screen. A typical footer might be as follows:

    end
    pause -1
    

    Nothing after the footer will be read by GNUplot.


    This page titled 25.2: Formatting Plot Files is shared under a CC BY-NC-SA 3.0 license and was authored, remixed, and/or curated by Ed Jorgensen via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.

    • Was this article helpful?