From b32f18cabc04df9b607a314b9a1ec0cea40ed103 Mon Sep 17 00:00:00 2001 From: Alex Povel Date: Mon, 12 Oct 2020 15:22:09 +0200 Subject: [PATCH 1/5] Introduce matlab2tikz example file --- data/matlab2tikz_table_example.tex | 149 +++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 data/matlab2tikz_table_example.tex diff --git a/data/matlab2tikz_table_example.tex b/data/matlab2tikz_table_example.tex new file mode 100644 index 0000000..7ff7417 --- /dev/null +++ b/data/matlab2tikz_table_example.tex @@ -0,0 +1,149 @@ +% This file was created by matlab2tikz. +% +%The latest updates can be retrieved from +% http://www.mathworks.com/matlabcentral/fileexchange/22022-matlab2tikz-matlab2tikz +%where you can also make suggestions and rate matlab2tikz. +% +\begin{tikzpicture} + +\begin{axis}[% +width=6.053in, +height=5.538in, +at={(1.338in,1.274in)}, +scale only axis, +xmin=0, +xmax=150000, +xlabel style={font=\color{white!15!black}}, +xlabel={Reynoldszahl [-]}, +ymin=-20, +ymax=60, +ylabel style={font=\color{white!15!black}}, +ylabel={Widerstandsbeiwert $\zeta$ [-]}, +axis background/.style={fill=white}, +axis x line*=bottom, +axis y line*=left, +xmajorgrids, +ymajorgrids, +legend style={legend cell align=left, align=left, draw=white!15!black} +] +\addplot [color=black, only marks, mark=o, mark options={solid, black}] + plot [error bars/.cd, y dir=both, y explicit, error bar style={line width=0.5pt}, error mark options={line width=0.5pt, mark size=6.0pt, rotate=90}] + table[row sep=crcr, y error plus index=2, y error minus index=3]{% +91450.4005348642 18.8206494302446 0.22784420833039 0.22784420833039\\ +9600.2287009917 17.0940855567971 18.8769483727188 18.8769483727188\\ +98040.7874556726 18.6728583096816 0.202036909770865 0.202036909770865\\ +65157.2349669312 19.3095953696594 0.418204806276939 0.418204806276939\\ +49337.9741089259 19.8795961310237 0.722764642682136 0.722764642682136\\ +16355.6858822063 21.6588058718839 6.48504129977849 6.48504129977849\\ +68662.1156767816 19.2826158073702 0.379906394244728 0.379906394244728\\ +88193.8884388812 18.8512612583498 0.241587510229639 0.241587510229639\\ +52897.2052503459 19.7556610691345 0.63682805169426 0.63682805169426\\ +45361.2310463829 19.9283864286216 0.857322986465614 0.857322986465614\\ +35629.1264772871 20.5353610928944 1.37414627818398 1.37414627818398\\ +95043.2938482082 18.7591297797428 0.213416328531058 0.213416328531058\\ +61640.0699375336 19.465583058119 0.466703246588861 0.466703246588861\\ +58751.4523099524 19.4914842217088 0.508777380354382 0.508777380354382\\ +41886.8624922781 20.2213805881069 0.988945957346638 0.988945957346638\\ +71787.1923690876 19.183171510498 0.349958881481435 0.349958881481435\\ +55566.6189222481 19.6884300185046 0.57492765151384 0.57492765151384\\ +22414.4905749956 21.4563894028588 3.46477796770842 3.46477796770842\\ +29891.5116045859 20.8072061681644 1.95317002720734 1.95317002720734\\ +81648.5561586976 18.9338775855205 0.276308105964505 0.276308105964505\\ +84915.3205825358 18.9018965006065 0.25775055811768 0.25775055811768\\ +12748.6992906755 20.956252098279 10.6964468685791 10.6964468685791\\ +19702.7655801537 21.3720690437585 4.47489311485873 4.47489311485873\\ +78363.5688516276 19.0751370068433 0.297546198952902 0.297546198952902\\ +32704.8269868436 20.8291059476584 1.63441062956786 1.63441062956786\\ +39454.0447791576 20.3956969160794 1.11850790152941 1.11850790152941\\ +25852.5857440217 21.5131319639883 2.60715319679087 2.60715319679087\\ +75047.302268985 19.1129078534408 0.322186799342343 0.322186799342343\\ +}; +\addlegendentry{9 bar, 30 $^\circ$C} + +\addplot [color=blue, only marks, mark=o, mark options={solid, blue}] + plot [error bars/.cd, y dir=both, y explicit, error bar style={line width=0.5pt}, error mark options={line width=0.5pt, mark size=6.0pt, rotate=90}] + table[row sep=crcr, y error plus index=2, y error minus index=3]{% +90364.8194858743 18.851972315629 0.305217342375055 0.305217342375055\\ +8076.2640578434 24.0111558434839 35.8029501848227 35.8029501848227\\ +50772.0591562781 19.7992917932574 0.928394801097195 0.928394801097195\\ +66195.4322434412 19.2914810641625 0.550235869227531 0.550235869227531\\ +47363.6661097263 20.0685366715685 1.0630574120011 1.0630574120011\\ +19902.7764508919 21.2759580135189 5.98521694141482 5.98521694141482\\ +39900.5151261104 20.5397185970455 1.48849529409474 1.48849529409474\\ +74866.732832787 19.0900594677447 0.434436734327329 0.434436734327329\\ +82545.9819399738 18.9439559950128 0.361002096005894 0.361002096005894\\ +106171.719883028 18.6283535384433 0.229496342278619 0.229496342278619\\ +94122.014260214 18.7599655960001 0.282619972807026 0.282619972807026\\ +55431.0307804117 19.61223734667 0.783444980800781 0.783444980800781\\ +59322.7541290298 19.6319108649163 0.684931628377185 0.684931628377185\\ +114221.038645558 18.4694576373584 0.203347977101083 0.203347977101083\\ +78925.5166005358 19.0282740070502 0.393135093952 0.393135093952\\ +63096.2993854333 19.3936301169532 0.605948000756784 0.605948000756784\\ +86358.0944477848 18.8993234493532 0.331341638288088 0.331341638288088\\ +110454.377590452 18.567036984956 0.214660611248231 0.214660611248231\\ +35864.0452240558 20.7795087552391 1.84052287954811 1.84052287954811\\ +102270.885599624 18.6534024509903 0.244662856478561 0.244662856478561\\ +15625.3491197509 23.0212986293325 9.68121139016299 9.68121139016299\\ +98275.2673711873 18.6797685109276 0.262281703155193 0.262281703155193\\ +31352.5742431042 21.0124223239215 2.41763424066977 2.41763424066977\\ +12313.9582502865 22.5336653922509 15.5170405633573 15.5170405633573\\ +118521.184105338 18.4634946805162 0.191715543444072 0.191715543444072\\ +27954.591413931 21.1733665963443 3.03909219686198 3.03909219686198\\ +23661.526874057 21.8398598857805 4.23960949267591 4.23960949267591\\ +70936.4289641694 19.2203716274935 0.481640104330054 0.481640104330054\\ +43616.6098039867 20.3724031756756 1.24623498410928 1.24623498410928\\ +}; +\addlegendentry{13.2 bar, 45 $^\circ$C} + +\addplot [color=red, only marks, mark=o, mark options={solid, red}] + plot [error bars/.cd, y dir=both, y explicit, error bar style={line width=0.5pt}, error mark options={line width=0.5pt, mark size=6.0pt, rotate=90}] + table[row sep=crcr, y error plus index=2, y error minus index=3]{% +17867.5515609687 21.7652508894877 9.15368581910848 9.15368581910848\\ +125637.055996345 18.3877470989716 0.20747930927834 0.20747930927834\\ +49304.731241175 19.807149989706 1.22247182825836 1.22247182825836\\ +107667.483438579 18.6074812032667 0.27078355428531 0.27078355428531\\ +13536.3513622991 22.9216117473262 16.0120267998002 16.0120267998002\\ +71994.5089139876 19.1461599074966 0.579982264504498 0.579982264504498\\ +58949.4992802703 19.4584247735011 0.863655495599455 0.863655495599455\\ +22441.0358182932 20.9345419939241 5.80047673858736 5.80047673858736\\ +44296.5080074942 19.8307916472566 1.50683347198268 1.50683347198268\\ +36163.6188854124 20.1076548679491 2.265078120627 2.265078120627\\ +121252.135326159 18.4363699283627 0.220566362796363 0.220566362796363\\ +85072.0354168332 18.8324850607434 0.418963400171204 0.418963400171204\\ +103030.125538593 18.6109968334098 0.292673058569925 0.292673058569925\\ +62664.4453756571 19.3182930613143 0.76166308494462 0.76166308494462\\ +66814.802347003 19.1511266386389 0.671621933741905 0.671621933741905\\ +40023.6860323227 20.3563108994464 1.84868057936682 1.84868057936682\\ +98428.0786967929 18.7052786521598 0.318212576297495 0.318212576297495\\ +94101.3387888276 18.7365240146046 0.345945890970535 0.345945890970535\\ +112249.405136342 18.541593643746 0.2517944419942 0.2517944419942\\ +31272.4427821611 20.5767680935139 3.01988954371356 3.01988954371356\\ +76452.8638484087 19.0625190030148 0.518185514149112 0.518185514149112\\ +53939.2603758079 19.6676345378916 1.02315173365127 1.02315173365127\\ +130240.937716863 18.3435824135538 0.195735083846963 0.195735083846963\\ +27281.4692961602 20.8755273958803 3.96092444894359 3.96092444894359\\ +81017.1760328248 18.9834687699148 0.462576998836875 0.462576998836875\\ +90129.3849290184 18.7809056600762 0.376175674619081 0.376175674619081\\ +134854.212682816 18.3289989496668 0.185163179879921 0.185163179879921\\ +116773.970377645 18.4532827516731 0.235074764576524 0.235074764576524\\ +}; +\addlegendentry{16.6 bar, 55 $^\circ$C} + +\end{axis} + +\begin{axis}[% +width=8.167in, +height=7.365in, +at={(0in,0in)}, +scale only axis, +xmin=0, +xmax=1, +ymin=0, +ymax=1, +axis line style={draw=none}, +ticks=none, +axis x line*=bottom, +axis y line*=left +] +\end{axis} +\end{tikzpicture}% From 9ab11e140864f25dc716a0046450ee81762e75ec Mon Sep 17 00:00:00 2001 From: Alex Povel Date: Mon, 12 Oct 2020 15:23:38 +0200 Subject: [PATCH 2/5] Translate to English --- data/matlab2tikz_table_example.tex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/matlab2tikz_table_example.tex b/data/matlab2tikz_table_example.tex index 7ff7417..ce5012e 100644 --- a/data/matlab2tikz_table_example.tex +++ b/data/matlab2tikz_table_example.tex @@ -14,11 +14,11 @@ xmin=0, xmax=150000, xlabel style={font=\color{white!15!black}}, -xlabel={Reynoldszahl [-]}, +xlabel={Reynold's Number [-]}, ymin=-20, ymax=60, ylabel style={font=\color{white!15!black}}, -ylabel={Widerstandsbeiwert $\zeta$ [-]}, +ylabel={Drag coefficient $\zeta$ [-]}, axis background/.style={fill=white}, axis x line*=bottom, axis y line*=left, From 56556a0a9c13a0b912850307b56ecc07120961d5 Mon Sep 17 00:00:00 2001 From: Alex Povel Date: Mon, 12 Oct 2020 15:25:57 +0200 Subject: [PATCH 3/5] Switch column separator for matlab2tikz example, allowing it to work --- data/matlab2tikz_table_example.tex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/data/matlab2tikz_table_example.tex b/data/matlab2tikz_table_example.tex index ce5012e..366e6e6 100644 --- a/data/matlab2tikz_table_example.tex +++ b/data/matlab2tikz_table_example.tex @@ -24,7 +24,8 @@ axis y line*=left, xmajorgrids, ymajorgrids, -legend style={legend cell align=left, align=left, draw=white!15!black} +legend style={legend cell align=left, align=left, draw=white!15!black}, +table/col sep=space, ] \addplot [color=black, only marks, mark=o, mark options={solid, black}] plot [error bars/.cd, y dir=both, y explicit, error bar style={line width=0.5pt}, error mark options={line width=0.5pt, mark size=6.0pt, rotate=90}] From 353b7bc8a771da9968496f197b6e76d8ad492e66 Mon Sep 17 00:00:00 2001 From: Alex Povel Date: Mon, 12 Oct 2020 15:28:53 +0200 Subject: [PATCH 4/5] Fix plot position and size Comment out so it is back at default, making it fit --- data/matlab2tikz_table_example.tex | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/data/matlab2tikz_table_example.tex b/data/matlab2tikz_table_example.tex index 366e6e6..2e6e649 100644 --- a/data/matlab2tikz_table_example.tex +++ b/data/matlab2tikz_table_example.tex @@ -7,9 +7,9 @@ \begin{tikzpicture} \begin{axis}[% -width=6.053in, -height=5.538in, -at={(1.338in,1.274in)}, +% width=6.053in, +% height=5.538in, +% at={(1.338in,1.274in)}, scale only axis, xmin=0, xmax=150000, @@ -133,9 +133,9 @@ \end{axis} \begin{axis}[% -width=8.167in, -height=7.365in, -at={(0in,0in)}, +% width=8.167in, +% height=7.365in, +% at={(0in,0in)}, scale only axis, xmin=0, xmax=1, From 0b668b05d2fab60bd50e4427824471173bb07b37 Mon Sep 17 00:00:00 2001 From: Alex Povel Date: Mon, 12 Oct 2020 15:52:38 +0200 Subject: [PATCH 5/5] Add new section for matlab2tikz plotting --- chapters/mainmatter/floats.tex | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/chapters/mainmatter/floats.tex b/chapters/mainmatter/floats.tex index 80a7c38..bd9e8b1 100644 --- a/chapters/mainmatter/floats.tex +++ b/chapters/mainmatter/floats.tex @@ -1323,6 +1323,35 @@ \subsubsection{Importing CSV} } \end{figure} +\subsubsection{Using MATLAB2Ti\textit{k}Z} + +\href{https://github.com/matlab2tikz/matlab2tikz}{MATLAB2Ti\textit{k}Z} is a tool to +convert MATLAB figures to \LaTeX{}, see \cref{fig:matlab2tikz}. +Notice that by default, it exports using whitespace (tabs) as column separators, +which might differ from what you set as a global option in \verb|\pgfplotstableset|. + +\begin{figure} + \ffigbox[\FBwidth]{% + \caption[% + A vanilla \href{https://github.com/matlab2tikz/matlab2tikz}{MATLAB2Ti\textit{k}Z} + example% + ]{% + A vanilla \href{https://github.com/matlab2tikz/matlab2tikz}{MATLAB2Ti\textit{k}Z} + example, imported here without changes except those to allow successful compilation + (see commit \texttt{56556a0}: set \texttt{table/col sep=space}). + While it works, the style created in MATLAB conflicts with the local one, + and you miss out on many useful features, like \ctanpackage{siunitx} or + \ctanpackage{glossaries-extra}. + A more frictionless approach is to export plain-text (CSV) data from MATLAB, + and import it into \LaTeX{}, see \cref{fig:diffuser}% + }% + \label{fig:matlab2tikz}% + }{% + % Can't use `subimport', since import is not from any child directory. + \import{data/}{matlab2tikz_table_example} + } +\end{figure} + \subsection{TikZ and Text} \idx{tikz} content can also be intertwined with text using \verb|\tikzmark|.