Gnuplot

From miki
Revision as of 22:33, 2 January 2018 by Mip (talk | contribs) (Created page with "== Reference == * [http://www.bersch.net/gnuplot-doc/gnuplot.html gnuplot documentation]. * [http://gnuplot.sourceforge.net/docs_4.2/node100.html#1861 <code>plot</code> comman...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Reference

Commands

Command-line

gnuplot -p -e 'plot "alacritty-deq-intel.txt" with lines lt rgb "royalblue"'

Plot

plot "urxvt-nvidia.txt" with lines
plot "urxvt-nvidia.txt" with lines lt rgb "orange"
plot "urxvt-nvidia.txt" with lines lt rgb "orange" dashtype 2

Examples

Plot from stdin

primes 1 100 |gnuplot -p -e 'plot "/dev/stdin"'

Heavy-side functions

(x) = ... define your first function
g(x) = ... define your second function
h(x) = (x<0.5)?f(x):g(x)
plot h(x)

To change color:

plot (x<0.5?f(x):1/0) lc 1, (x>0.5?g(x):1/0) lc 2

Plot one or several files

plot "alacritty-deq-intel.txt" with lines lt rgb "royalblue"

To plot several files on the same graph, just separate with a comma ,:

plot "alacritty-deq-intel.txt" with lines lt rgb "royalblue", "alacritty-intel.txt" with lines lt rgb "brown"

Set graph range

set yrange [0:2.5]

Set location of the legend

set key right bottom;

Plot with dash

Use a predefined dashtype:

plot x dashtype 2

We can define custom dashtype [1]:

plot x dashtype (3,5,10,5),\
     2*x dashtype '.-_'

To change the default linetype to dashtype:

set for [i=1:8] linetype i dashtype i

To change the colorset:

set colorsequence default|podo|classi

Output to a file

To generate a .png:

et terminal pngcairo dashed
set output 'test.png'
test
set output

To generate a .eps:

set terminal postscript eps color colortext
set output 'test.eps'
test
set output