1

I am trying to use gnuplot to make a 'live' plot embedded in a C application, but I have encountered something that I want to change.

I am using gnuplot_i to 'interface' with gnuplot as if I were using gnuplot in the terminal. Whenever I plot (two lines) I save the data to a file to then tell gnuplot to load the file and plot.

I would like to not have to save a data file and load the data directly into gnuplot. I do not know much of gnuplot so there may be a simple solution for what I want. What I would like is to have a command like this:

plot [1,2,3,4], [1,1,1,1], [1,2,3,4], [2,2,2,2]
     |_____line 1_______|  |______line 2______|

Is there a way to do this in gnuplot?

1 Answer 1

3
gnuplot> help datablock
 There are two mechanisms for embedding data into a stream of gnuplot commands.
 If the special filename '-' appears in a plot command, then the lines
 immediately following the plot command are interpreted as inline data.
 See `special-filenames`.  Data provided in this way can only be used once, by
 the plot command it follows.

 The second mechanism defines a named data block as a here-document.  The named
 data is persistent and may be referred to by more than one plot command.
 Example:
      $Mydata << EOD
      11 22 33 first line of data
      44 55 66 second line of data
      # comments work just as in a data file
      77 88 99
      EOD
      stats $Mydata using 1:3
      plot $Mydata using 1:3 with points, $Mydata using 1:2 with impulses

 Data block names must begin with a $ character, which distinguishes them from
 other types of persistent variables.  The end-of-data delimiter (EOD in the
 example) may be any sequence of alphanumeric characters.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.