| 1 |
<!DOCTYPE html> |
| 2 |
<html><head> |
| 3 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> |
| 4 |
<title>test.gp</title> |
| 5 |
<meta name="generator" content="KF5::SyntaxHighlighting - Definition (Gnuplot) - Theme (Breeze Dark)"/> |
| 6 |
</head><body style="background-color:#232629;color:#cfcfc2"><pre> |
| 7 |
<span style="font-weight:bold;">set</span> <span style="color:#27aeae;font-weight:bold;">terminal</span> pdf |
| 8 |
<span style="font-weight:bold;">plot</span> <span style="color:#f67400;">"data-simple"</span> <span style="color:#27aeae;font-weight:bold;">using</span> <span style="color:#f67400;">1</span><span style="color:#2980b9;">:</span><span style="color:#f67400;">2</span> <span style="color:#27aeae;font-weight:bold;">with</span> <span style="color:#2980b9;">lines</span><span style="font-weight:bold;">,</span> \ |
| 9 |
<span style="color:#f67400;">"data-simple"</span> <span style="color:#27aeae;font-weight:bold;">using</span> <span style="color:#f67400;">1</span><span style="color:#2980b9;">:</span><span style="color:#f67400;">3</span> <span style="color:#27aeae;font-weight:bold;">with</span> <span style="color:#2980b9;">linespoints</span> |
| 10 |
|
| 11 |
<span style="color:#7a7c7d;"># simple plotting</span> |
| 12 |
<span style="font-weight:bold;">plot</span> <span style="color:#f67400;">'2col.dat'</span> <span style="color:#7a7c7d;"># assumes col1=x, col2=y; shows '+' at data points</span> |
| 13 |
<span style="font-weight:bold;">plot</span> <span style="color:#f67400;">'2col.dat'</span> <span style="color:#27aeae;font-weight:bold;">with</span> <span style="color:#2980b9;">lines</span> <span style="color:#7a7c7d;"># connect points with a line</span> |
| 14 |
|
| 15 |
<span style="color:#7a7c7d;"># plot a subset of the data</span> |
| 16 |
<span style="font-weight:bold;">plot</span><span style="color:#2980b9;">[</span><span style="color:#f67400;">1</span><span style="color:#2980b9;">:</span><span style="color:#f67400;">5</span><span style="color:#2980b9;">]</span> <span style="color:#f67400;">'2col.dat'</span> <span style="color:#27aeae;font-weight:bold;">with</span> <span style="color:#2980b9;">linespoints</span> <span style="color:#7a7c7d;"># plot the first 5 elements</span> |
| 17 |
|
| 18 |
<span style="color:#7a7c7d;"># add a title to your line</span> |
| 19 |
<span style="font-weight:bold;">plot</span> <span style="color:#f67400;">'2col.dat'</span> <span style="color:#27aeae;font-weight:bold;">with</span> <span style="color:#2980b9;">lines</span> <span style="color:#27aeae;font-weight:bold;">title</span> <span style="color:#f67400;">'my curve'</span> <span style="color:#7a7c7d;"># this is really the line-title in the legend</span> |
| 20 |
|
| 21 |
<span style="color:#7a7c7d;"># map the columns to the x- and y-axes</span> |
| 22 |
<span style="font-weight:bold;">plot</span> <span style="color:#f67400;">'2col.dat'</span> <span style="color:#27aeae;font-weight:bold;">using</span> <span style="color:#f67400;">1</span><span style="color:#2980b9;">:</span><span style="color:#f67400;">2</span> <span style="color:#7a7c7d;"># 1=x, 2=y (this is the default)</span> |
| 23 |
<span style="font-weight:bold;">plot</span> <span style="color:#f67400;">'2col.dat'</span> <span style="color:#27aeae;font-weight:bold;">using</span> <span style="color:#f67400;">2</span><span style="color:#2980b9;">:</span><span style="color:#f67400;">1</span> <span style="color:#7a7c7d;"># 2=x, 1=y (reverse the graph)</span> |
| 24 |
|
| 25 |
<span style="color:#7a7c7d;"># abbreviations</span> |
| 26 |
<span style="font-weight:bold;">plot</span> <span style="color:#f67400;">'2col.csv'</span> <span style="color:#27aeae;font-weight:bold;">u</span> <span style="color:#f67400;">1</span><span style="color:#2980b9;">:</span><span style="color:#f67400;">2</span> <span style="color:#27aeae;font-weight:bold;">w</span> <span style="color:#2980b9;">l</span> <span style="color:#27aeae;font-weight:bold;">title</span> <span style="color:#f67400;">'Squared'</span> <span style="color:#7a7c7d;"># 'u' - using, 'w l' - with lines</span> |
| 27 |
|
| 28 |
<span style="font-weight:bold;">set</span> <span style="color:#27aeae;font-weight:bold;">title</span> <span style="color:#f67400;">'Hello, world'</span> <span style="color:#7a7c7d;"># plot title</span> |
| 29 |
<span style="font-weight:bold;">set</span> <span style="color:#27aeae;font-weight:bold;">xlabel</span> <span style="color:#f67400;">'Time'</span> <span style="color:#7a7c7d;"># x-axis label</span> |
| 30 |
<span style="font-weight:bold;">set</span> <span style="color:#27aeae;font-weight:bold;">ylabel</span> <span style="color:#f67400;">'Distance'</span> <span style="color:#7a7c7d;"># y-axis label</span> |
| 31 |
|
| 32 |
<span style="color:#7a7c7d;"># labels</span> |
| 33 |
<span style="font-weight:bold;">set</span> <span style="color:#27aeae;font-weight:bold;">label</span> <span style="color:#f67400;">"boiling point"</span> <span style="color:#27aeae;font-weight:bold;">at</span> <span style="color:#f67400;">10</span><span style="font-weight:bold;">,</span> <span style="color:#f67400;">212</span> |
| 34 |
|
| 35 |
<span style="color:#7a7c7d;"># key/legend</span> |
| 36 |
<span style="font-weight:bold;">set</span> <span style="color:#27aeae;font-weight:bold;">key</span> <span style="color:#2980b9;">top</span> <span style="color:#2980b9;">right</span> |
| 37 |
<span style="font-weight:bold;">set</span> <span style="color:#27aeae;font-weight:bold;">key</span> <span style="color:#2980b9;">box</span> |
| 38 |
<span style="font-weight:bold;">set</span> <span style="color:#27aeae;font-weight:bold;">key</span> <span style="color:#2980b9;">left</span> <span style="color:#2980b9;">bottom</span> |
| 39 |
<span style="font-weight:bold;">set</span> <span style="color:#27aeae;font-weight:bold;">key</span> <span style="color:#2980b9;">bmargin</span> |
| 40 |
<span style="font-weight:bold;">set</span> <span style="color:#27aeae;font-weight:bold;">key</span> <span style="color:#f67400;">0.01</span><span style="font-weight:bold;">,</span><span style="color:#f67400;">100</span> |
| 41 |
|
| 42 |
<span style="font-weight:bold;">set</span> <span style="color:#27aeae;font-weight:bold;">nokey</span> <span style="color:#7a7c7d;"># no key</span> |
| 43 |
|
| 44 |
<span style="color:#7a7c7d;"># arrow</span> |
| 45 |
<span style="font-weight:bold;">set</span> <span style="color:#27aeae;font-weight:bold;">arrow</span> <span style="color:#27aeae;font-weight:bold;">from</span> <span style="color:#f67400;">1</span><span style="font-weight:bold;">,</span><span style="color:#f67400;">1</span> <span style="color:#27aeae;font-weight:bold;">to</span> <span style="color:#f67400;">5</span><span style="font-weight:bold;">,</span><span style="color:#f67400;">10</span> |
| 46 |
|
| 47 |
<span style="font-weight:bold;">set</span> <span style="color:#27aeae;font-weight:bold;">multiplot</span> <span style="color:#7a7c7d;"># multiplot mode (prompt changes to 'multiplot')</span> |
| 48 |
<span style="font-weight:bold;">set</span> <span style="color:#27aeae;font-weight:bold;">size</span> <span style="color:#f67400;">1</span><span style="font-weight:bold;">,</span> <span style="color:#f67400;">0.5</span> |
| 49 |
|
| 50 |
<span style="font-weight:bold;">set</span> <span style="color:#27aeae;font-weight:bold;">origin</span> <span style="color:#f67400;">0.0</span><span style="font-weight:bold;">,</span><span style="color:#f67400;">0.5</span> |
| 51 |
<span style="font-weight:bold;">plot</span> <span style="color:#8e44ad;">sin</span>(x)<span style="font-weight:bold;">,</span> <span style="color:#8e44ad;">log</span>(x) |
| 52 |
|
| 53 |
<span style="font-weight:bold;">set</span> <span style="color:#27aeae;font-weight:bold;">origin</span> <span style="color:#f67400;">0.0</span><span style="font-weight:bold;">,</span><span style="color:#f67400;">0.0</span> |
| 54 |
<span style="font-weight:bold;">plot</span> <span style="color:#8e44ad;">sin</span>(x)<span style="font-weight:bold;">,</span> <span style="color:#8e44ad;">log</span>(x)<span style="font-weight:bold;">,</span> <span style="color:#8e44ad;">cos</span>(x) |
| 55 |
|
| 56 |
<span style="font-weight:bold;">unset</span> <span style="color:#27aeae;font-weight:bold;">multiplot</span> <span style="color:#7a7c7d;"># exit multiplot mode (prompt changes back to 'gnuplot')</span> |
| 57 |
|
| 58 |
<span style="font-weight:bold;">plot</span> <span style="color:#8e44ad;">sin</span>(x) <span style="color:#27aeae;font-weight:bold;">title</span> <span style="color:#f67400;">'Sine Function'</span><span style="font-weight:bold;">,</span> <span style="color:#8e44ad;">tan</span>(x) <span style="color:#27aeae;font-weight:bold;">title</span> <span style="color:#f67400;">'Tangent'</span> |
| 59 |
|
| 60 |
<span style="font-weight:bold;">plot</span> <span style="color:#8e44ad;">sin</span>(x) |
| 61 |
<span style="font-weight:bold;">plot</span> <span style="color:#8e44ad;">sin</span>(x)<span style="color:#3f8058;">/</span>x |
| 62 |
|
| 63 |
<span style="font-weight:bold;">plot</span> <span style="color:#f67400;">'bp-hr.dat'</span> <span style="color:#27aeae;font-weight:bold;">u</span> <span style="color:#f67400;">1</span><span style="color:#2980b9;">:</span><span style="color:#f67400;">2</span> <span style="color:#27aeae;font-weight:bold;">w</span> <span style="color:#2980b9;">lp</span> <span style="color:#27aeae;font-weight:bold;">t</span> <span style="color:#f67400;">'systolic'</span><span style="font-weight:bold;">,</span> <span style="color:#f67400;">'bp-hr.dat'</span> <span style="color:#27aeae;font-weight:bold;">u</span> <span style="color:#f67400;">1</span><span style="color:#2980b9;">:</span><span style="color:#f67400;">3</span> <span style="color:#27aeae;font-weight:bold;">w</span> <span style="color:#2980b9;">lp</span> <span style="color:#27aeae;font-weight:bold;">t</span> <span style="color:#f67400;">'diastolic'</span><span style="font-weight:bold;">,</span> <span style="color:#f67400;">'bp-hr.dat'</span> <span style="color:#27aeae;font-weight:bold;">u</span> <span style="color:#f67400;">1</span><span style="color:#2980b9;">:</span><span style="color:#f67400;">4</span> <span style="color:#27aeae;font-weight:bold;">w</span> <span style="color:#2980b9;">lp</span> <span style="color:#27aeae;font-weight:bold;">t</span> <span style="color:#f67400;">'heartrate'</span> |
| 64 |
|
| 65 |
<span style="font-weight:bold;">set</span> <span style="color:#27aeae;font-weight:bold;">terminal</span> <span style="color:#2980b9;">postscript</span> color <span style="color:#27aeae;font-weight:bold;">noenhanced</span> <span style="color:#7a7c7d;">##setting the term</span> |
| 66 |
<span style="font-weight:bold;">set</span> <span style="color:#27aeae;font-weight:bold;">output</span> <span style="color:#f67400;">"multiple_files.ps"</span> |
| 67 |
|
| 68 |
<span style="font-weight:bold;">set</span> <span style="color:#27aeae;font-weight:bold;">key</span> center <span style="color:#7a7c7d;">##legend placement</span> |
| 69 |
|
| 70 |
<span style="font-weight:bold;">plot</span> <span style="color:#2980b9;">[</span><span style="color:#f67400;">1</span><span style="color:#2980b9;">:</span><span style="color:#f67400;">5</span><span style="color:#2980b9;">][</span><span style="color:#f67400;">1</span><span style="color:#2980b9;">:</span><span style="color:#f67400;">120</span><span style="color:#2980b9;">]</span> \ |
| 71 |
<span style="color:#fdbc4b;font-weight:bold;">for</span> <span style="color:#2980b9;">[</span><span style="color:#27aeae;">i</span> <span style="color:#3f8058;">=</span> <span style="color:#f67400;">1</span><span style="color:#2980b9;">:</span><span style="color:#f67400;">3</span><span style="color:#2980b9;">]</span> <span style="color:#f67400;">"file_"</span><span style="color:#3f8058;">.</span>i<span style="color:#3f8058;">.</span><span style="color:#f67400;">".dat"</span> \ |
| 72 |
<span style="color:#27aeae;font-weight:bold;">pointsize</span> <span style="color:#f67400;">1.3</span> <span style="color:#27aeae;font-weight:bold;">linecolor</span> i<span style="color:#3f8058;">+</span><span style="color:#f67400;">4</span> \ |
| 73 |
<span style="color:#27aeae;font-weight:bold;">title</span> <span style="color:#f67400;">"file</span><span style="color:#3daee9;">\_</span><span style="color:#f67400;">"</span><span style="color:#3f8058;">.</span>i<span style="color:#3f8058;">.</span><span style="color:#f67400;">".dat"</span> \ |
| 74 |
<span style="color:#27aeae;font-weight:bold;">with</span> <span style="color:#2980b9;">linespoints</span> |
| 75 |
|
| 76 |
|
| 77 |
<span style="color:#8e44ad;">file_name</span>(<span style="color:#27aeae;">n</span>) <span style="color:#3f8058;">=</span> <span style="color:#8e44ad;">sprintf</span>(<span style="color:#f67400;">"file_%d.dat"</span><span style="font-weight:bold;">,</span> <span style="color:#27aeae;">n</span>) |
| 78 |
<span style="font-weight:bold;">plot</span> <span style="color:#fdbc4b;font-weight:bold;">for</span><span style="color:#2980b9;">[</span><span style="color:#27aeae;">i</span> <span style="color:#3f8058;">=</span> <span style="color:#f67400;">1</span><span style="color:#2980b9;">:</span><span style="color:#27aeae;">N</span><span style="color:#2980b9;">]</span> <span style="color:#8e44ad;">file_name</span>(i) <span style="color:#27aeae;font-weight:bold;">title</span> <span style="color:#8e44ad;">file_name</span>(i) |
| 79 |
|
| 80 |
|
| 81 |
<span style="color:#7a7c7d;"># data blocks</span> |
| 82 |
<span style="color:#27aeae;">$Mydata</span> << <span style="color:#da4453;">EOD</span> |
| 83 |
<span style="color:#f67400;">11</span> <span style="color:#f67400;">22</span> <span style="color:#f67400;">33</span> first line of data |
| 84 |
<span style="color:#f67400;">44</span> <span style="color:#f67400;">55</span> <span style="color:#f67400;">66</span> second line of data |
| 85 |
<span style="color:#7a7c7d;"># comments work just as in a data file</span> |
| 86 |
<span style="color:#f67400;">77</span> <span style="color:#f67400;">88</span> <span style="color:#f67400;">99</span> |
| 87 |
<span style="color:#da4453;">EOD</span> |
| 88 |
<span style="font-weight:bold;">stats</span> <span style="color:#27aeae;">$Mydata</span> <span style="color:#27aeae;font-weight:bold;">using</span> <span style="color:#f67400;">1</span><span style="color:#2980b9;">:</span><span style="color:#f67400;">3</span> |
| 89 |
<span style="font-weight:bold;">plot</span> <span style="color:#27aeae;">$Mydata</span> <span style="color:#27aeae;font-weight:bold;">using</span> <span style="color:#f67400;">1</span><span style="color:#2980b9;">:</span><span style="color:#f67400;">3</span> <span style="color:#27aeae;font-weight:bold;">with</span> <span style="color:#2980b9;">points</span><span style="font-weight:bold;">,</span> <span style="color:#27aeae;">$Mydata</span> <span style="color:#27aeae;font-weight:bold;">using</span> <span style="color:#f67400;">1</span><span style="color:#2980b9;">:</span><span style="color:#f67400;">2</span> <span style="color:#27aeae;font-weight:bold;">with</span> <span style="color:#2980b9;">impulses</span> |
| 90 |
|
| 91 |
<span style="font-weight:bold;">print</span> <span style="color:#f67400;">'`hostname -s`: '</span><span style="color:#3f8058;">.</span><span style="color:#f67400;">"</span><span style="font-weight:bold;">`</span><span style="color:#8e44ad;">hostname</span> <span style="color:#2980b9;">-s</span><span style="font-weight:bold;">`</span><span style="color:#f67400;">"</span> |
| 92 |
|
| 93 |
<span style="color:#27aeae;">style1</span> <span style="color:#3f8058;">=</span> <span style="color:#f67400;">"lines lt 4 lw 2"</span> |
| 94 |
<span style="color:#27aeae;">style2</span> <span style="color:#3f8058;">=</span> <span style="color:#f67400;">"points lt 3 pt 5 ps 2"</span> |
| 95 |
<span style="color:#27aeae;">range1</span> <span style="color:#3f8058;">=</span> <span style="color:#f67400;">"using 1:3"</span> |
| 96 |
<span style="color:#27aeae;">range2</span> <span style="color:#3f8058;">=</span> <span style="color:#f67400;">"using 1:5"</span> |
| 97 |
<span style="font-weight:bold;">plot</span> <span style="color:#f67400;">"foo"</span> <span style="color:#27ae60;">@range1</span> <span style="color:#27aeae;font-weight:bold;">with</span> <span style="color:#27ae60;">@style1</span><span style="font-weight:bold;">,</span> <span style="color:#f67400;">"bar"</span> <span style="color:#27ae60;">@range2</span> <span style="color:#27aeae;font-weight:bold;">with</span> <span style="color:#27ae60;">@style2</span> |
| 98 |
|
| 99 |
<span style="color:#27aeae;">v</span><span style="color:#3f8058;">=</span><span style="color:#f67400;">0</span> |
| 100 |
<span style="color:#fdbc4b;font-weight:bold;">if</span> (<span style="color:#27aeae;">v</span><span style="color:#3f8058;">%</span><span style="color:#f67400;">2</span>) { |
| 101 |
<span style="font-weight:bold;">print</span> <span style="color:#f67400;">"2"</span> |
| 102 |
} <span style="color:#fdbc4b;font-weight:bold;">else</span> <span style="color:#fdbc4b;font-weight:bold;">if</span> (<span style="color:#27aeae;">v</span><span style="color:#3f8058;">%</span><span style="color:#f67400;">3</span>) { |
| 103 |
<span style="font-weight:bold;">print</span> <span style="color:#f67400;">"3"</span> |
| 104 |
} <span style="color:#fdbc4b;font-weight:bold;">else</span> { |
| 105 |
<span style="font-weight:bold;">print</span> <span style="color:#f67400;">"fred"</span> |
| 106 |
} |
| 107 |
|
| 108 |
<span style="color:#27aeae;">v</span><span style="color:#3f8058;">=</span><span style="color:#27aeae;">v</span><span style="color:#3f8058;">+</span><span style="color:#f67400;">1</span>; <span style="color:#fdbc4b;font-weight:bold;">if</span> (<span style="color:#27aeae;">v</span><span style="color:#3f8058;">%</span><span style="color:#f67400;">2</span>) <span style="font-weight:bold;">print</span> <span style="color:#f67400;">"2"</span> ; <span style="color:#fdbc4b;font-weight:bold;">else</span> <span style="color:#fdbc4b;font-weight:bold;">if</span> (<span style="color:#27aeae;">v</span><span style="color:#3f8058;">%</span><span style="color:#f67400;">3</span>) <span style="font-weight:bold;">print</span> <span style="color:#f67400;">"3"</span>; <span style="color:#fdbc4b;font-weight:bold;">else</span> <span style="font-weight:bold;">print</span> <span style="color:#f67400;">"fred"</span> |
| 109 |
|
| 110 |
<span style="font-weight:bold;">do</span> <span style="color:#fdbc4b;font-weight:bold;">for</span> <span style="color:#2980b9;">[</span><span style="color:#27aeae;">N</span><span style="color:#3f8058;">=</span><span style="color:#f67400;">1</span><span style="color:#2980b9;">:</span><span style="color:#f67400;">5</span><span style="color:#2980b9;">]</span> { |
| 111 |
<span style="font-weight:bold;">plot</span> <span style="color:#8e44ad;">func</span>(N<span style="font-weight:bold;">,</span> x) |
| 112 |
<span style="font-weight:bold;">pause</span> <span style="color:#3f8058;">-</span><span style="color:#f67400;">1</span> |
| 113 |
} |
| 114 |
</pre></body></html> |