├── README.md ├── output_terminals ├── terminal_eps.gnu ├── terminal_epslatex.gnu ├── terminal_epslatex_ugly.gnu └── terminal_png.gnu ├── plotting_data ├── battery.dat ├── battery.gnu ├── battery_data.gnu ├── plotting_data1.dat ├── plotting_data1.gnu ├── plotting_data2.dat ├── plotting_data2.gnu ├── plotting_data3.dat └── plotting_data3.gnu └── plotting_functions ├── plotting_functions.gnu └── plotting_functions_ugly.gnu /README.md: -------------------------------------------------------------------------------- 1 | gnuplot-basics 2 | ============== 3 | 4 | gnuplot code for the entries under "gnuplot basics" on http://www.gnuplotting.org 5 | -------------------------------------------------------------------------------- /output_terminals/terminal_eps.gnu: -------------------------------------------------------------------------------- 1 | #!/usr/bin/gnuplot 2 | # 3 | # Demonstrates a simple usage of gnuplot. 4 | # 5 | # AUTHOR: Hagen Wierstorf 6 | 7 | reset 8 | 9 | # eps 10 | set terminal postscript eps size 3.5,2.62 enhanced color font 'Helvetica,20' lw 2 11 | set output 'terminal_eps.eps' 12 | # Line styles 13 | set border linewidth 1.5 14 | set style line 1 linecolor rgb '#0060ad' linetype 1 linewidth 2 # blue 15 | set style line 2 linecolor rgb '#dd181f' linetype 1 linewidth 2 # red 16 | # Legend 17 | set key at 6.1,1.3 18 | # Axes label 19 | set xlabel '{/Helvetica-Oblique x}' 20 | set ylabel '{/Helvetica-Oblique y}' 21 | # Axis ranges 22 | set xrange[-2*pi:2*pi] 23 | set yrange[-1.5:1.5] 24 | # Axis labels 25 | set xtics ('-2{/Symbol p}' -2*pi, '-{/Symbol p}' -pi, 0, '{/Symbol p}' pi, \ 26 | '2{/Symbol p}' 2*pi) 27 | set ytics 1 28 | set tics scale 0.75 29 | # Functions to plot 30 | a = 0.9 31 | f(x) = a * sin(x) 32 | g(x) = a * cos(x) 33 | # Plot 34 | plot f(x) title 'sin({/Helvetica-Oblique x})' with lines ls 1, \ 35 | g(x) notitle with lines ls 2 36 | 37 | -------------------------------------------------------------------------------- /output_terminals/terminal_epslatex.gnu: -------------------------------------------------------------------------------- 1 | #!/usr/bin/gnuplot 2 | # 3 | # Demonstrates a simple usage of gnuplot. 4 | # 5 | # AUTHOR: Hagen Wierstorf 6 | 7 | reset 8 | 9 | # epslatex 10 | # NOTE: thes ize is given in inches. It can also be given in cm. 11 | set terminal epslatex size 3.5,2.62 standalone color colortext 10 12 | set output 'terminal_epslatex.tex' 13 | 14 | # Line styles 15 | set border linewidth 2 16 | set style line 1 linecolor rgb '#0060ad' linetype 1 linewidth 5 # blue 17 | set style line 2 linecolor rgb '#dd181f' linetype 1 linewidth 5 # red 18 | # Legend 19 | set key at 6.1,1.3 20 | # Axes label 21 | set xlabel '$x$' 22 | set ylabel '$y$' 23 | # Axis ranges 24 | set xrange[-2*pi:2*pi] 25 | set yrange[-1.5:1.5] 26 | # Tics in LaTeX format 27 | set format '$%g$' 28 | # Axis labels 29 | set xtics ('$-2\pi$' -2*pi, '$-\pi$' -pi, 0, '$\pi$' pi, '$2\pi$' 2*pi) 30 | set ytics 1 31 | set tics scale 1.25 32 | # Functions to plot 33 | a = 0.9 34 | f(x) = a * sin(x) 35 | g(x) = a * cos(x) 36 | # Plot 37 | plot f(x) title '$\sin(x)$' with lines ls 1, \ 38 | g(x) notitle with lines ls 2 39 | 40 | -------------------------------------------------------------------------------- /output_terminals/terminal_epslatex_ugly.gnu: -------------------------------------------------------------------------------- 1 | #!/usr/bin/gnuplot 2 | # 3 | # Demonstrates a simple usage of gnuplot. 4 | # 5 | # AUTHOR: Hagen Wierstorf 6 | 7 | reset 8 | 9 | # epslatex 10 | set terminal epslatex size 3.5,2.62 standalone color colortext 10 11 | set output 'terminal_epslatex_ugly.tex' 12 | 13 | # Line styles 14 | set border linewidth 1.5 15 | set style line 1 linecolor rgb '#0060ad' linetype 1 linewidth 2 # blue 16 | set style line 2 linecolor rgb '#dd181f' linetype 1 linewidth 2 # red 17 | # Legend 18 | set key at 6.1,1.3 19 | # Axes label 20 | set xlabel '$x$' 21 | set ylabel '$y$' 22 | # Axis ranges 23 | set xrange[-2*pi:2*pi] 24 | set yrange[-1.5:1.5] 25 | # Axis labels 26 | set format '$%g$' 27 | set xtics ('$-2\pi$' -2*pi, '$-\pi$' -pi, 0, '$\pi$' pi, '$2\pi$' 2*pi) 28 | set ytics 1 29 | set tics scale 0.75 30 | # Functions to plot 31 | a = 0.9 32 | f(x) = a * sin(x) 33 | g(x) = a * cos(x) 34 | # Plot 35 | plot f(x) title '$\sin(x)$' with lines ls 1, \ 36 | g(x) notitle with lines ls 2 37 | 38 | -------------------------------------------------------------------------------- /output_terminals/terminal_png.gnu: -------------------------------------------------------------------------------- 1 | #!/usr/bin/gnuplot 2 | # 3 | # Demonstrates a simple usage of gnuplot. 4 | # 5 | # AUTHOR: Hagen Wierstorf 6 | 7 | reset 8 | 9 | # png 10 | set terminal pngcairo size 350,262.5 enhanced font 'Verdana,10' 11 | set output 'terminal_png.png' 12 | 13 | # Line styles 14 | set border linewidth 1.5 15 | set style line 1 linecolor rgb '#0060ad' linetype 1 linewidth 2 # blue 16 | set style line 2 linecolor rgb '#dd181f' linetype 1 linewidth 2 # red 17 | # Legend 18 | set key at 6.1,1.3 19 | # Axes label 20 | set xlabel 'x' 21 | set ylabel 'y' 22 | 23 | 24 | # Axis ranges 25 | set xrange[-2*pi:2*pi] 26 | set yrange[-1.5:1.5] 27 | # Axis labels 28 | set xtics ("-2π" -2*pi, "-π" -pi, 0, "π" pi, "2π" 2*pi) 29 | set ytics 1 30 | set tics scale 0.75 31 | # Functions to plot 32 | a = 0.9 33 | f(x) = a * sin(x) 34 | g(x) = a * cos(x) 35 | # Plot 36 | plot f(x) title 'sin(x)' with lines ls 1, \ 37 | g(x) notitle with lines ls 2 38 | 39 | -------------------------------------------------------------------------------- /plotting_data/battery.dat: -------------------------------------------------------------------------------- 1 | # 2 | # $Id: battery.dat,v 1.1.1.1 1998/04/15 19:16:41 lhecking Exp $ 3 | # 4 | 50.000000 0.036990 2.500000 0.007039 5 | 47.000000 0.036990 2.500000 0.007039 6 | 44.000000 0.038360 2.500000 0.007053 7 | 41.000000 0.042160 2.500000 0.007050 8 | 38.000000 0.043200 2.500000 0.007018 9 | 35.000000 0.046900 2.500000 0.007021 10 | 32.000000 0.048840 2.500000 0.006963 11 | 29.000000 0.052000 2.500000 0.006929 12 | 26.000000 0.055470 2.500000 0.006947 13 | 23.000000 0.060000 2.500000 0.006882 14 | 20.000000 0.064660 2.500000 0.006879 15 | 17.000000 0.069600 2.500000 0.006936 16 | 14.000000 0.079800 2.500000 0.007080 17 | 11.000000 0.086920 2.500000 0.007232 18 | 8.000000 0.085500 2.500000 0.007262 19 | 5.000000 0.101260 2.500000 0.008415 20 | 2.000000 0.091000 2.500000 0.011203 21 | 0.000000 0.081480 2.500000 0.011828 22 | -------------------------------------------------------------------------------- /plotting_data/battery.gnu: -------------------------------------------------------------------------------- 1 | #!/usr/bin/gnuplot 2 | # 3 | # Plotting data about battery power (see battery.dat) 4 | # 5 | # AUTHOR: Hagen Wierstorf 6 | 7 | reset 8 | 9 | # png 10 | set terminal pngcairo size 350,262 enhanced font 'Verdana,10' 11 | set output 'battery.png' 12 | 13 | set border linewidth 1.5 14 | # Set first two line styles to blue (#0060ad) and red (#dd181f) 15 | set style line 1 linecolor rgb '#0060ad' linetype 1 linewidth 2 16 | set style line 2 linecolor rgb '#dd181f' linetype 1 linewidth 2 pointtype 7 17 | 18 | set key at 50,112 19 | set xlabel 'Resistance (Ω)' 20 | set ylabel 'Power (mW)' 21 | set tics scale 0.75 22 | 23 | # Theoretical curve 24 | P(x) = 1.53**2 * x/(5.67+x)**2 * 1000 25 | 26 | set xrange [-2:52] 27 | set yrange [0:120] 28 | 29 | plot 'battery.dat' u 1:($2*1000):($4*1000) title 'Power' with yerrorbars ls 2, \ 30 | P(x) title 'Theory' with lines ls 1 31 | -------------------------------------------------------------------------------- /plotting_data/battery_data.gnu: -------------------------------------------------------------------------------- 1 | #!/usr/bin/gnuplot 2 | # 3 | # Plotting data about battery power (see battery.dat) 4 | # 5 | # AUTHOR: Hagen Wierstorf 6 | 7 | reset 8 | 9 | # png 10 | set terminal pngcairo size 350,262 enhanced font 'Verdana,10' 11 | set output 'battery_data.png' 12 | 13 | set border linewidth 1.5 14 | # Set color of linestyle 1 to blue (#0060ad) 15 | set style line 1 linecolor rgb '#0060ad' linetype 1 linewidth 2 pointtype 7 16 | 17 | unset key 18 | set xlabel 'Resistance (Ω)' 19 | set ylabel 'Power (mW)' 20 | set tics scale 0.75 21 | 22 | set xrange [-2:52] 23 | set yrange [0:0.12] 24 | set format y '%.0s' 25 | 26 | plot 'battery.dat' using 1:2:4 with yerrorbars linestyle 1, \ 27 | '' with lines linestyle 1 28 | -------------------------------------------------------------------------------- /plotting_data/plotting_data1.dat: -------------------------------------------------------------------------------- 1 | # X Y 2 | 1 2 3 | 2 3 4 | 3 2 5 | 4 1 6 | -------------------------------------------------------------------------------- /plotting_data/plotting_data1.gnu: -------------------------------------------------------------------------------- 1 | #!/usr/bin/gnuplot 2 | # 3 | # Plotting the data of file plotting_data1.dat 4 | # 5 | # AUTHOR: Hagen Wierstorf 6 | 7 | reset 8 | 9 | # png 10 | set terminal pngcairo size 350,262 enhanced font 'Verdana,10' 11 | set output 'plotting_data1.png' 12 | 13 | set border linewidth 1.5 14 | # Set first linestyle to blue (#0060ad) 15 | set style line 1 \ 16 | linecolor rgb '#0060ad' \ 17 | linetype 1 linewidth 2 \ 18 | pointtype 7 pointsize 1.5 19 | 20 | unset key 21 | 22 | set ytics 1 23 | set tics scale 0.75 24 | 25 | set xrange [0:5] 26 | set yrange [0:4] 27 | 28 | plot 'plotting_data1.dat' with linespoints linestyle 1 29 | -------------------------------------------------------------------------------- /plotting_data/plotting_data2.dat: -------------------------------------------------------------------------------- 1 | # X Y 2 | 1 2 3 | 2 3 4 | 5 | 3 2 6 | 4 1 7 | -------------------------------------------------------------------------------- /plotting_data/plotting_data2.gnu: -------------------------------------------------------------------------------- 1 | #!/usr/bin/gnuplot 2 | # 3 | # Plotting the data of file plotting_data2.dat 4 | # 5 | # AUTHOR: Hagen Wierstorf 6 | 7 | reset 8 | 9 | # png 10 | set terminal pngcairo size 350,262 enhanced font 'Verdana,10' 11 | set output 'plotting_data2.png' 12 | 13 | set border linewidth 1.5 14 | # Set first linestyle to blue (#0060ad) 15 | set style line 1 \ 16 | linecolor rgb '#0060ad' \ 17 | linetype 1 linewidth 2 \ 18 | pointtype 7 pointsize 1.5 19 | 20 | unset key 21 | 22 | set ytics 1 23 | set tics scale 0.75 24 | 25 | set xrange [0:5] 26 | set yrange [0:4] 27 | 28 | plot 'plotting_data2.dat' with linespoints ls 1 29 | -------------------------------------------------------------------------------- /plotting_data/plotting_data3.dat: -------------------------------------------------------------------------------- 1 | # First data block (index 0) 2 | # X Y 3 | 1 2 4 | 2 3 5 | 6 | 7 | # Second data block (index 1) 8 | # X Y 9 | 3 2 10 | 4 1 11 | -------------------------------------------------------------------------------- /plotting_data/plotting_data3.gnu: -------------------------------------------------------------------------------- 1 | #!/usr/bin/gnuplot 2 | # 3 | # Plotting the data of file plotting_data3.dat 4 | # 5 | # AUTHOR: Hagen Wierstorf 6 | 7 | reset 8 | 9 | # png 10 | set terminal pngcairo size 350,262 enhanced font 'Verdana,10' 11 | set output 'plotting_data3.png' 12 | 13 | set border linewidth 1.5 14 | # Set first two line styles to blue (#0060ad) and red (#dd181f) 15 | set style line 1 \ 16 | linecolor rgb '#0060ad' \ 17 | linetype 1 linewidth 2 \ 18 | pointtype 7 pointsize 1.5 19 | set style line 2 \ 20 | linecolor rgb '#dd181f' \ 21 | linetype 1 linewidth 2 \ 22 | pointtype 5 pointsize 1.5 23 | 24 | unset key 25 | 26 | set ytics 1 27 | set tics scale 0.75 28 | 29 | set xrange [0:5] 30 | set yrange [0:4] 31 | 32 | plot 'plotting_data3.dat' index 0 with linespoints linestyle 1, \ 33 | '' index 1 with linespoints linestyle 2 34 | -------------------------------------------------------------------------------- /plotting_functions/plotting_functions.gnu: -------------------------------------------------------------------------------- 1 | #!/usr/bin/gnuplot 2 | # 3 | # Plot trigonometric functions with Gnuplot. 4 | # 5 | # AUTHOR: Hagen Wierstorf 6 | 7 | reset 8 | 9 | # png 10 | set terminal pngcairo size 350,262 enhanced font 'Verdana,10' 11 | set output 'plotting_functions.png' 12 | 13 | set border linewidth 1.5 14 | # Set first two line styles to blue (#0060ad) and red (#dd181f) 15 | set style line 1 linecolor rgb '#0060ad' linetype 1 linewidth 2 16 | set style line 2 linecolor rgb '#dd181f' linetype 1 linewidth 2 17 | # Legend 18 | set key at 6.1,1.3 19 | # Axes label 20 | set xlabel 'x' 21 | set ylabel 'y' 22 | 23 | 24 | # Axis ranges 25 | set xrange[-2*pi:2*pi] 26 | set yrange[-1.5:1.5] 27 | # Axis labels 28 | set xtics ("-2π" -2*pi, "-π" -pi, 0, "π" pi, "2π" 2*pi) 29 | set ytics 1 30 | set tics scale 0.75 31 | # Functions to plot 32 | a = 0.9 33 | f(x) = a * sin(x) 34 | g(x) = a * cos(x) 35 | # Plot 36 | plot f(x) title 'sin(x)' with lines linestyle 1, \ 37 | g(x) notitle with lines linestyle 2 38 | -------------------------------------------------------------------------------- /plotting_functions/plotting_functions_ugly.gnu: -------------------------------------------------------------------------------- 1 | #!/usr/bin/gnuplot 2 | # 3 | # Plot trigonometric functions with Gnuplot 4 | # 5 | # AUTHOR: Hagen Wierstorf 6 | 7 | reset 8 | 9 | # png 10 | set terminal pngcairo size 350,262 enhanced font 'Verdana,10' 11 | set output 'plotting_functions_ugly.png' 12 | 13 | set border linewidth 1.5 14 | # Set first two line styles to blue (#0060ad) and red (#dd181f) 15 | set style line 1 linecolor rgb '#0060ad' linetype 1 linewidth 2 16 | set style line 2 linecolor rgb '#dd181f' linetype 1 linewidth 2 17 | 18 | # Functions to plot 19 | a = 0.9 20 | f(x) = a * sin(x) 21 | g(x) = a * cos(x) 22 | 23 | # Plot 24 | plot f(x) title 'sin(x)' with lines linestyle 1, \ 25 | g(x) notitle with lines linestyle 2 26 | 27 | --------------------------------------------------------------------------------