Dante Herbsttagung 21 Institut für Chemische Verfahrenstechnik TU Clausthal ICVT 1
Motivation / Ziel Motivation... alles aus einem Guss aber warum dann GNUplot-Diagramme einbinden? Ziel Diagramme für einen Artikel schwarz/weiß-diagramme nicht jeden Befehl merken ICVT 2
Motivation / Ziel Motivation... alles aus einem Guss aber warum dann GNUplot-Diagramme einbinden? Ziel Diagramme für einen Artikel schwarz/weiß-diagramme nicht jeden Befehl merken ICVT 2
Motivation / Ziel Motivation... alles aus einem Guss aber warum dann GNUplot-Diagramme einbinden? Ziel Diagramme für einen Artikel schwarz/weiß-diagramme nicht jeden Befehl merken ICVT 2
Grundlagen Paket laden 1 \input pgfplots.tex % Plain TeX \usepackage{pgfplots} % LaTeX \usemodule[pgfplots] % ConTeXt ICVT 3
Grundlagen Paket laden 1 \input pgfplots.tex % Plain TeX \usepackage{pgfplots} % LaTeX \usemodule[pgfplots] % ConTeXt Standardachse 1 \begin{tikzpicture} \begin{axis} % Plot code \end{axis} 5 \end{tikzpicture} 1.5.5 1 ICVT 3
Grundlagen Paket laden 1 \input pgfplots.tex % Plain TeX \usepackage{pgfplots} % LaTeX \usemodule[pgfplots] % ConTeXt logarithmische x-achse 1 \begin{tikzpicture} \begin{semilogxaxis} % Plot code \end{semilogxaxis} 5 \end{tikzpicture} 1.5 1 1.2 1.4 ICVT 3
Grundlagen Paket laden 1 \input pgfplots.tex % Plain TeX \usepackage{pgfplots} % LaTeX \usemodule[pgfplots] % ConTeXt logarithmische Achsen 1 \begin{tikzpicture} \begin{loglogaxis} % Plot code \end{loglogaxis} 5 \end{tikzpicture} 1.4 1.2 1 1 1.2 1.4 ICVT 3
Grundlagen Paket laden 1 \input pgfplots.tex % Plain TeX \usepackage{pgfplots} % LaTeX \usemodule[pgfplots] % ConTeXt logarithmische Achsen 1 \begin{tikzpicture} \begin{loglogaxis} % Plot code \end{loglogaxis} 5 \end{tikzpicture} 1.4 1.2 1 1 1.2 1.4 neue Verbesserungen nutzen 1 \pgfplotsset{compat = newest} ICVT 3
Kleiner Datensatz Concentration Rate / mmol dm 3 / s 1 338.1 266.45 169.1 143.43 84.5 64.8 42.3 34.19 21.1 9.47 ICVT 4
Kleiner Datensatz Concentration Rate / mmol dm 3 / s 1 338.1 266.45 169.1 143.43 84.5 64.8 42.3 34.19 21.1 9.47 1 \addplot coordinates { ( 338.1, 266.45 ) ( 169.1, 143.43 ) ( 84.5, 64.8 ) 5 ( 42.3, 34.19 ) ( 21.1, 9.47 ) }; 2 1 1 2 3 ICVT 4
Kleiner Datensatz Concentration Rate / mmol dm 3 / s 1 338.1 266.45 169.1 143.43 84.5 64.8 42.3 34.19 21.1 9.47 1 \addplot coordinates { ( 338.1, 266.45 ) ( 169.1, 143.43 ) ( 84.5, 64.8 ) 5 ( 42.3, 34.19 ) ( 21.1, 9.47 ) }; 2 1 1 2 3 keine Farbe keine Linien ICVT 4
Kleiner Datensatz 1 \addplot[ color = black, fill = black, mark = *, 5 only marks ] coordinates { ( 338.1, 266.45 ) ( 169.1, 143.43 ) ( 84.5, 64.8 ) 1 ( 42.3, 34.19 ) ( 21.1, 9.47 ) }; 2 1 1 2 3 ICVT 4
Kleiner Datensatz 1 \addplot[ color = black, fill = black, mark = *, 5 only marks ] coordinates { ( 338.1, 266.45 ) ( 169.1, 143.43 ) ( 84.5, 64.8 ) 1 ( 42.3, 34.19 ) ( 21.1, 9.47 ) }; 2 1 1 2 3 Trendlinie hinzufügen ICVT 4
Kleiner Datensatz 1 \addplot[ color = black, fill = black, mark = *, 5 only marks ] coordinates {... }; \addplot[ color = black, 1 mark = none ] coordinates { (, ) ( 35, 279 ) 15 }; 3 2 1 1 2 3 ICVT 4
Kleiner Datensatz 1 \addplot[ color = black, fill = black, mark = *, 5 only marks ] coordinates {... }; \addplot[ color = black, 1 mark = none ] coordinates { (, ) ( 35, 279 ) 15 }; 3 2 1 1 2 3 Achsen beschriften Achsenlimits anpassen ICVT 4
Kleiner Datensatz 1 \begin{axis}[ xlabel = Concentration\,/\,% mmol\,dm$^{-3}$, 5 xmax = 4, xmin =, ylabel = Rate\,/\,s$^{-1}$, ymax = 3, ymin = 1 ]... Rate / s 1 3 2 1 1 2 3 4 Concentration / mmol dm 3 ICVT 4
Großer Datensatz Datenfile data-set-two.txt 1 Time a b c d 49 7 41 1.3 67 55 9 33 1.6 134 61 1 26 1.9 5 2 65 12 2 1.9... ICVT 5
Großer Datensatz Datenfile data-set-two.txt 1 Time a b c d 49 7 41 1.3 67 55 9 33 1.6 134 61 1 26 1.9 5 2 65 12 2 1.9... Einlesen des Datenfiles 1 \pgfplotstableread{data-set-two.txt} \datatable ICVT 5
Großer Datensatz Erzeugen des Plots 1 \pgfplotstableread{data-set-two.txt} \datatable \addplot table[y = a] from \datatable ; 5 \addplot table[y = b] from \datatable ; \addplot table[y = c] from \datatable ; \addplot table[y = d] from \datatable ; 6 4 2 5 1, ICVT 5
Großer Datensatz Alternative 1 \pgfplotstableread{data-set-two.txt} \datatable 6 4 2 5 5 1, \addplot table[y = a] from \datatable ; \addplot table[y = b] {data-set-two.txt} ; 1 \addplot table[y index = 3] {data-set-two.txt} ; \addplot table[y index = 4] from \datatable ; ICVT 5
Großer Datensatz Hinzufügen einer Legende 1 \addplot table[y = a] from \datatable ; \addplot table[y = b] from \datatable ; \addplot table[y = c] from \datatable ; \addplot table[y = d] from \datatable ; 5 \legend{% Component \textbf{a}, Component \textbf{b}, Component \textbf{c}, 1 Component \textbf{d}, } 6 4 2 Component a Component b Component c Component d 5 1, ICVT 5
Großer Datensatz Alternative 1 \begin{axis}[ legend entries = {% Component \textbf{a}, Component \textbf{b}, 5 Component \textbf{c}, Component \textbf{d}, }, ] 1 \addplot table[y = a] from \datatable ; \addplot table[y = b] from \datatable ; \addplot table[y = c] from \datatable ; \addplot table[y = d] from \datatable ; 6 4 2 Component a Component b Component c Component d 5 1, ICVT 5
Großer Datensatz Noch eine Alternative 1 \addplot table[y = a] from \datatable ; \addlegendentry{% Component \textbf{a}}; \addplot table[y = b] from \datatable ; 5 \addlegendentry{% Component \textbf{b}};... 6 4 2 Component a Component b Component c Component d 5 1, ICVT 5
Großer Datensatz Schönheitskorrekturen Achsenbeschriftungen hinzufügen Linien entfernen 1er Trenner entfernen 1 \pgfkeys{ /pgf/number format/ set thousands separator = } Relative amount / % 8 6 4 2 Component a Component b Component c Component d 2 4 6 8 1 Time / s ICVT 5
Großer Datensatz Eigene Marker definieren 1 \pgfdeclareplotmark{halfcircle}{% \begin{pgfscope} \pgfsetfillcolor{white}% \pgfpathcircle{\pgfpoint{pt}{pt}} 5 {\pgfplotmarksize} \pgfusepathqfillstroke \end{pgfscope}% \pgfpathmoveto {\pgfpoint{\pgfplotmarksize}{pt}} 1 \pgfpatharc{}{18}{\pgfplotmarksize} \pgfpathclose \pgfusepathqfill } Ergebnis (2 %) ICVT 6
Großer Datensatz neuen Marker verwenden 1 \addplot[mark = halfcircle,...... mit Optionen 1 \addplot[ mark = halfcircle, mark options = {rotate = 9}, Legende verschieben 1 [ ] legend style = { at = {(.6,.75)}} ICVT 7
Relative amount / % 8 7 6 5 4 3 2 1 Component a Component b Component c Component d 2 4 6 8 1 Time / s ICVT 8
Ein experimentelles Spektrum 1 [ was wir schon kennen xlabel = Chemische Verschiebung\,/\,ppm, xmin = 18,.5 5 xmax = 24, ymax = 1.25, ymin = ] \addplot[ 18 2 22 24 color = black, Chemische Verschiebung / ppm 1 mark = none ] table {plots/data/data-set-three.txt}; 1 ICVT 9
Ein experimentelles Spektrum y-achsenbeschriftung entfernen 1 [yticklabels = ] 18 2 22 24 Chemical shift / ppm ICVT 1
Ein experimentelles Spektrum y-achsenbeschriftung entfernen 1 [yticklabels = ] x-achse umdrehen 1 \addplot[ x dir = reverse,... 24 22 2 18 Chemical shift / ppm ICVT 1
Ein experimentelles Spektrum Peaks beschriften 1 \node[ coordinate, pin = {[rotate=9]right:22.26} ] at (axis cs:22.26,1.1) { }; 22.26 ICVT 11
Ein experimentelles Spektrum Peaks beschriften 1 \node[ coordinate, pin = {[rotate=9]right:22.26} ] at (axis cs:22.26,1.1) { }; 22.26 gedrehte Beschriftung 1 \node[ coordinate, pin = {[rotate=9]5:22.32} ] at (axis cs:22.32,1.1) { }; 22.32 ICVT 11
Ein experimentelles Spektrum 1 [ x dir = reverse, xlabel = Chemical shift\,/\,ppm, xmin = 18, 5 xmax = 24, ymax = 1.75, ymin =, yticklabels = ] \addplot[ 1 color = black, mark = none ] table from {plots/data/data-set-three.txt}; 22.32 22.26 21.96 21.9 21.26 19.3 18.32 \node[ 15 coordinate, pin = {[rotate=9]5:22.32} ] at (axis cs:22.32,1.1) { }; \node[ coordinate, pin = {[rotate=9]right:22.26} 2 ] at (axis cs:22.26,1.1) { };... 24 23 22 21 2 19 18 Chemical shift / ppm ICVT 12
Funktionen mit GNUplot Formel E(Θ) = K (K Θ)K 1 (K 1)! exp( K Θ) ICVT 13
Funktionen mit GNUplot Formel E(Θ) = K 1 % number of CSTRs \newcommand\k{3} (K Θ)K 1 (K 1)! exp( K Θ) E(Θ) 1.8.6.4.2 \addplot gnuplot[ 5 id=cascade_model_full, domain=\xmin:\xmax, samples=11, ] {\K * (\K*x)^(\K-1) / (\K-1)! 1 * exp(-\k * x)}; 1 2 3 Θ -shell-escape nicht vergessen ICVT 13
Funktionen mit GNUplot cascade_model_full.gnuplot 1 set table "cascade_model_full.table"; set format "%.5f" set format "%.7e";; set samples 11; set dummy x,y; plot [x=:3] 3* (3* cascade_model_full.table 1 # Curve of 1, 11 points # Curve title: "3* (3*x)**(3-1) / (3-1)! * exp(-3* x)" # x y type.e+.e+ i 3.e-2 1.114264e-2 i 6.e-2 4.594132e-2 i... ICVT 14
Funktionen mit GNUplot 1 E(Θ).8.6.4 Anteil des abfließenden Stromes, der älter als Θ ist..2.5 1 1.5 2 2.5 3 Θ Θ ICVT 15
Berechnungen mit GNUplot (und Co.) erstes Beispiel noch einmal (Kleiner Datensatz) 3 Rate / s 1 2 1 1 2 3 4 Concentration / mmol dm 3 ICVT 16
Berechnungen mit GNUplot (und Co.) erstes Beispiel noch einmal (Kleiner Datensatz) 1... % plot regression curve with GNUplot (calculated also by GNUplot) \addplot [raw gnuplot] gnuplot [id=conc_rate] { 5 % define function which should be fitted f(x)=a*x; % let gnuplot fit using column 1 and 2 of the data file fit f(x) conc_rate.txt using 1:2 via a; % Plot the function with the specified plot range 1 plot [x=\xmin:35] f(x); }; ICVT 16
Berechnungen mit GNUplot (und Co.) erstes Beispiel noch einmal (Kleiner Datensatz) 3 measured data external program + pgfplots 2 external program + GNUplot everything GNUplot everything pgfplots Rate / s 1 1 1 2 3 4 Concentration / mmol dm 3 ICVT 16
Rate / Berechnungen mit GNUplot (und Co.) erstes Beispiel noch einmal (Kleiner Datensatz) Rate / s 1 3 2 1 1 measured measured data external program + pgfplots external program + GNUplot everything external GNUplot p everything pgfplots external p everything Concentration everything Diagramme erstellen mit / pgfplots mm 1 2 3 1 2 3 4 Concentration / mmol dm 3 ICVT 16
Diagramme exportieren nach PDF 1 \usetikzlibrary{pgfplots.external} \tikzexternalize nach EPS ICVT 17
Diagramme exportieren nach PDF 1 \usetikzlibrary{pgfplots.external} \tikzexternalize nach EPS 1 \tikzset{external/system call = {latex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"; dvips -o "\image".ps "\image".dvi}} ICVT 17
Zusammenfassung pgfplots ist ein mächtiges Paket zum Erstellen von Diagrammen Die Diagramme sind verschiedensten Typs (Linien, Balken, 2D, 3D, Dreieck) hoher Qualität konsistent zum restlichen Dokument leicht anpassbar im Stil Keine Drittsoftware nötig ICVT 18
Literatur J. Wright Plotting experimental data using pgfplots TUGboat 31:1, 21, p. 5 https: //www.tug.org/members/tugboat/tb31-1/tb97wright-pgfplots.pdf Chr. Feuersänger pgfplots manual http://pgfplots.sourceforge.net/pgfplots.pdf http://pgfplots.sourceforge.net/pgfplotstable.pdf T. Tantau pgf / TikZ manual http://sourceforge.net/projects/pgf ICVT 19
2 25 15 Using Coordinate Filters to fix z = 1.4 1 φxφy φx φy 2 1.8 1.5.2.4.6.8 1.5 1 15 1 5 1 2 3 5 2 4 6 8 1 12 14 16 1min load nodes cpus processes 1 7 f(x, y) = x y 1.2.4.6.8 x 1.5 y 1.6.4.2 12 7 7 6.5 15 1.5 1.8.6.4.2 1.5 115 11 15 1 4 2 2 4 Population 6 5 4 3 5 5 4.5 4.2 4.3 4 3.8 3.3 193 194 195 196 197 Far Near 1 5 5 1 15 6 4 2 2 4 6 1 9 7 1 5 tan(x) 5 l3 3 1 1 1 1 3 l2 5 7 9 1 1 3 5 7 9 l1.5.5 1 1.5 2.5 1 1 1 6 1 3 2 π π/2 π/2 3 2 π 5 L2 Error 1 1 1 2 1 3 1 4 d = 2 d = 3 d = 4 d = 5 d = 6 3, model estimate 2, 1, 1,.5.4.3 1 1 5 1 1 1 2 1 3 1 4 1 5 1 6 Degrees of freedom 2, 3, 6 4 2 2 4 6.2 Class 1 Class 2.1 Class 3 Line.2.4.6.8 1 4 2 2 4 2 2 4 4