function gsegraf_plot(varargin)

   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   %
   % Function writes a plot-parameter file, opens a temporary file for
   % communication with the plotting program, and then uses gsegraf to create
   % the plot. When the plot is completed, gsegraf writes the string "complete"
   % to the temporary file. The function then deletes the temporary file and
   % plot-parameter file.
   %
   % Input
   %    fname:           plot-parameter file-name (including path)
   %    keyword1   arg1: first keyword-argument pair
   %    keyword2   arg2: second keyword-argument pair
   %                               etc
   %
   % All inputs must be strings (enclosed in double quotes) and separated by
   % commas. If all or part of an argument needs to be quoted in the plot-
   % parameter file, the double-quote escape sequence (\") must be used for
   % these additional quotes. An example of how to call gsegraf_plot is:
   %
   %    gsegraf_plot("./sinc_param.txt",
   %                 "file_name     \"./sinc.txt\"",
   %                 "file_format   \"%lf %lf\"",
   %                 "plot_type     \"points\"",
   %                 "plot_style    lk",
   %                 "axis_type     \"linear\"",
   %                 "grid          ls",
   %                 "xlabel        \"x axis\"",
   %                 "ylabel        \"y axis\"",
   %                 "title         \"sin(x)/x\"");
   %
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

   % Write plot-parameter file
   narg = length(varargin);
   fname = varargin{1};
   fid = fopen(fname, "w");
   for ( i = 2:narg )
      fprintf(fid, "%s\n", varargin{i});
   end
   fclose(fid);

   % Plot data
   [fid, tempfile, msg] = mkstemp("gsegraf_XXXXXX", 1);
   system(["gsegraf " fname " " tempfile " &"]);

   % Wait for plot to be completed
   while ( fgets(fid, 1) == -1 )
      pause(0.1);
      frewind(fid);
   end
   fclose(fid);
   delete(tempfile);

   % Delete plot-parameter file
   delete(fname);
end