Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to plot data without a separate file by specifying all points inside the Gnuplot script?

Tags:

gnuplot

My program generates bash scripts that call gnuplot. I don't want to have to make an extra file to store the data; is there any way I can explicitly call all of the values? Or possibly having bash make a temporary file.

Something like

plot {(1,5),(2,10),(3,1)} 

is what I am looking for.

like image 411
rhombidodecahedron Avatar asked Jul 23 '10 12:07

rhombidodecahedron


People also ask

How use gnuplot to plot data from a file?

To plot functions simply type: plot [function] at the gnuplot> prompt. Discrete data contained in a file can be displayed by specifying the name of the data file (enclosed in quotes) on the plot or splot command line. Data files should have the data arranged in columns of numbers.

How the plot generated by gnuplot may be saved in a file?

There are two ways to save your work in gnuplot: you can save the gnuplot commands used to generate a plot, so that you can regenerate the plot at a later time. Or you can export the graph to a file in a standard graphics file format, so that you can print it or include it in web pages, documents, or presentations.

Does gnuplot support multiple Y axes on a single plot?

5.9 Does gnuplot support multiple y-axes on a single plot? Yes.

What are possible output formats of gnuplot?

png, and svg terminal It exists also a png terminal, but it produces uglier output and doesn't use the UTF-8 encoding the cairo library does. You may also have noticed that we set the size to a given x,y value. If we don't do this, the default value of 640,480 is used.


1 Answers

You can use the syntax for inline data - filename '-'.

The following example produces a simple plot in a GIF image (bash script):

gnuplot << EOF set terminal gif set output 'plot1.gif' plot '-' using 1:2         1 10         2 20         3 32         4 40         5 50         e EOF 
like image 58
gimel Avatar answered Sep 19 '22 15:09

gimel