Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to plot line with missing data points in gnuplot

Tags:

gnuplot

Example:

enter image description here

I want to plot a chart just like above one: a line with some missing data points, that means the line is discontinuous.

How can I do this?

like image 459
ZhenYu Wang Avatar asked Aug 22 '12 16:08

ZhenYu Wang


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.

Is gnuplot easy?

gnuplot is a not-quite-as-easy-to use, though extremely powerful, command-line plotting program. Running gnuplot is easy: from a command prompt on any system, type gnuplot.

Does R use gnuplot?

gnuplot can be used from various programming languages to graph data, including Perl (via PDL and other CPAN packages), Python (via gnuplotlib, Gnuplot-py and SageMath), R via (Rgnuplot), Julia (via Gaston.

Why do we use gnuplot?

gnuplot is a command-driven interactive function plotting program. It can be used to plot functions and data points in both two- and three- dimensional plots in many different formats. It is designed primarily for the visual display of scientific data.


1 Answers

This depends on what your datafile looks like. If you insert a blank space in your datafile, it won't connect those adjacent points (This is the easiest way):

consider:

 #datafile
 1 2
 2 3

 4 2
 5 3

and then the script to plot it:

 plot 'datafile' u 1:2 w linespoints

There are other tricks you can play with missing data: set datafile missing. A good reference for this is the builtin help (help missing).

like image 169
mgilson Avatar answered Oct 03 '22 03:10

mgilson