gnuplot
Inhaltsverzeichnis
GnuPlot
Fehlermeldungen
bei dieser Fehlermeldung ist in meinem Fall ein Update schuld gewesen:
"gnuplot.plt", line 22: warning: Warning - difficulty fitting plot titles into key
"gnuplot.plt", line 22: warning: Terminal canvas area too small to hold plot.
Check plot boundary and font sizes.
in der Version 4.2 war die Syntax für das Terminal noch so:
set terminal png enhanced size 800 600
in der Version 4.4 musste die Syntax für das Terminal dann so aussehen:
set terminal png enhanced size 800,600
Der Unterschied ist nur ein Komma!
Die Korrektur musste ich in Zeile "5" machen, in der Warning wurde aber Zeile "22" genannt.
Erste Schritte mit GNU-Plot
Installation unter FreeBSD
cd /usr/ports/math/gnuplot ; make install && make clean
Hinweis:
(2D) ===> plot (3D) ===> splot
interaktiver Modus
> gnuplot show # Anzeige der Einstellungen show all # zeigt alle Einstellungen an help # Hilfe help set # Hilfe help set term # Hilfe help commands # Hilfe help commands splot # Hilfe help commands plot # Hilfe
Ausgabe nach X11
set terminal x11
Ausgabe im PostScript-Format in Datei "out.ps"
set terminal postscript set output "out.ps"
schreiben in "Ausgabe" (2D)
plot x*y
Beispiele:
plot sin(x) plot f(x) = sin(x*a), a = .2, f(x), a = .4, f(x) plot [t=1:10] [-pi:pi*2] tan(t)
schreiben in "Ausgabe" (3D)
splot x*y*z
Beispiel einer Darstellung einer Population mit "plot":
> vi population.dat 1965 103 1970 55 1975 34 1980 24 1985 10
> gnuplot gnuplot> pop(x) = 103*exp((1965-x)/10) gnuplot> plot [1960:1990] 'population.dat', pop(x)
Beispiel einer Darstellung einer Population mit "plot":
> vi datafile.dat 0 0 10 0 1 10 0 2 10 1 0 10 1 1 5 1 2 10 2 0 10 2 1 1 2 2 10 3 0 10 3 1 0 3 2 10
> gnuplot gnuplot> splot 'datafile.dat'
batch Mode
Ausgabe im PNG-Format auf die Datei "plotout.png" einstellen
> echo 'set terminal png' >> .gnuplot > echo 'set output "plotout.png"' >> .gnuplot
Input-Datei erstellen
> echo "splot f(x) = sin(x*a), a = .2, f(x), a = .4, f(x)" > gnuplot-input
gnuplot im Batch-Mode starten
> gnuplot gnuplot-input "G N U P L O T Version 3.7 patchlevel 2" kann folgende Ausgabeformate: ---------------------------------------------------------------------- aed512 aed767 aifm bitgraph cgm corel dumb dxf eepic emf emtex epslatex epson-180dpi epson-60dpi epson-lx800 fig gpic hp2623a hp2648 hp500c hpdj hpgl hpljii hppj imagen kc-tek40xx km-tek40xx latex mf mif mp nec-cp6 okidata pbm pcl5 pdf png postscript pslatex pstex pstricks qms regis selanar starc svg table tandy-60dpi tek40xx tek410x texdraw tgif tkcanvas tpic vttek x11 xlib
Beispiele
2 Spalten
- 2-Spalten-Grafik.plt
set terminal svg enhanced size 1280 960 fixed set output "/tmp/2-Spalten-Grafik.svg" set object 1 rectangle from screen 0,0 to screen 1,1 fillcolor rgb "white" behind set samples 1001 # high quality set border 31 linewidth .3 # thin border set grid set xdata time # x-Achse wird im Datums/Zeitformat skaliert set timefmt "%Y-%m-%d_%H" # Format der vorliegenden Datums- oder Zeitangaben set format x "%Y-%m-%d, %H Uhr" # Format für die Achsenbeschriftung set xlabel "Zeit" set ylabel "Anzahl" set xtics rotate set boxwidth 0.85 relative set style fill solid 1.0 set key left top #outside box plot "/tmp/2-Spalten.dat" using 1:2 with linespoints lc rgb 'blue' title ' Spalte 2'
2017-04-09_10 1318 2017-04-09_11 1796 2017-04-09_12 5155 2017-04-09_13 2038 2017-04-09_14 1698 2017-04-09_15 1915 2017-04-09_16 2809 2017-04-09_17 1596 2017-04-09_18 2662 2017-04-09_19 1520 2017-04-09_20 2649 2017-04-09_21 1548 2017-04-09_22 3318 2017-04-09_23 1769
> gnuplot 2-Spalten-Grafik.plt
3 Spalten
- 3-Spalten-Grafik.plt
set terminal svg enhanced size 1280 960 fixed set output "/tmp/3-Spalten-Grafik.svg" set object 1 rectangle from screen 0,0 to screen 1,1 fillcolor rgb "white" behind set samples 1001 # high quality set border 31 linewidth .3 # thin border set grid set xdata time # x-Achse wird im Datums/Zeitformat skaliert set timefmt "%Y-%m-%d_%H" # Format der vorliegenden Datums- oder Zeitangaben set format x "%Y-%m-%d, %H Uhr" # Format für die Achsenbeschriftung set xlabel "Zeit" set ylabel "Anzahl" set xtics rotate set boxwidth 0.85 relative set style fill solid 1.0 set key left top #outside box plot "/tmp/3-Spalten.dat" using 1:2 with linespoints lc rgb 'blue' title ' Spalte 2', "/tmp/3-Spalten.dat" using 1:3 with linespoints lc rgb 'red' title ' Spalte 3'
2017-04-09_10 1318 1881 2017-04-09_11 1796 2015 2017-04-09_12 5155 1802 2017-04-09_13 2038 1140 2017-04-09_14 1698 1209 2017-04-09_15 1915 1372 2017-04-09_16 2809 1151 2017-04-09_17 1596 1229 2017-04-09_18 2662 1291 2017-04-09_19 1520 1044 2017-04-09_20 2649 1550 2017-04-09_21 1548 1392 2017-04-09_22 3318 1785 2017-04-09_23 1769 1091
> gnuplot 3-Spalten-Grafik.plt
/home/http/wiki/data/pages/gnuplot.txt · Zuletzt geändert: von manfred
