Wed, 06 Nov 2024 14:58:31 -0500
Add visualisation TikZ
| 21 | 1 | \documentclass[tikz]{standalone} |
| 2 | \usepackage{pgfplots} | |
| 3 | \usepackage{tikz-3dplot} | |
| 4 | \usepgfplotslibrary{colorbrewer} | |
| 5 | ||
| 6 | \def\datapath{../res/} | |
| 7 | ||
| 8 | \begin{document} | |
| 9 | ||
| 10 | \tdplotsetmaincoords{50}{25} | |
| 11 | ||
| 12 | \def\onlyfront#1{ | |
| 13 | \ifnum#1=2\else\ifnum#1=4\else\ifnum#1=6\else | |
| 14 | \def\pgfmathresult{} | |
| 15 | \fi\fi\fi} | |
| 16 | ||
| 17 | \def\onlyback#1{ | |
| 18 | \ifnum#1=1\else\ifnum#1=3\else\ifnum#1=5\else | |
| 19 | \def\pgfmathresult{} | |
| 20 | \fi\fi\fi} | |
| 21 | ||
| 22 | \pgfplotsset{ | |
| 23 | % forget plot = no legend | |
| 24 | cube/.style = {thick, gray!50!black,forget plot}, | |
| 25 | iter/.style = {mark=x, red}, | |
| 26 | data/.style = {mark=*, blue, only marks}, | |
| 27 | backdata/.style = {mark=*, blue!30!white, only marks, onlyback, forget plot}, | |
| 28 | backiter/.style = {mark=x, red!30!white, onlyback, forget plot}, | |
| 29 | origin/.style = {mark=o, green, only marks, thick}, | |
| 30 | surfstyle/.style = {very nearly opaque, forget plot}, | |
| 31 | onlyfront/.code = \pgfplotsset{x filter/.code={\onlyfront{\thisrow{face}}}}, | |
| 32 | onlyback/.code = \pgfplotsset{x filter/.code={\onlyback{\thisrow{face}}}}, | |
| 33 | legend style = { | |
| 34 | inner sep = 0pt, | |
| 35 | outer xsep = 5pt, | |
| 36 | outer ysep = 0pt, | |
| 37 | legend cell align = left, | |
| 38 | align = left, | |
| 39 | draw = none, | |
| 40 | fill = none, | |
| 41 | font = \small | |
| 42 | }, | |
| 43 | } | |
| 44 | ||
| 45 | \begin{tikzpicture} | |
| 46 | \begin{axis}[ | |
| 47 | colormap access=map, | |
| 48 | colormap/Blues,%RdPu-6, | |
| 49 | colorbar, | |
| 50 | point meta rel=axis wide, | |
| 51 | shader = interp, | |
| 52 | xlabel = {$x$}, | |
| 53 | ylabel = {$y$}, | |
| 54 | zlabel = {$z$}, | |
| 55 | ticks = none, | |
| 56 | axis line style = {draw=none}, | |
| 57 | %axis x line = none, | |
| 58 | %axis y line = none, | |
| 59 | %axis z line = none, | |
| 60 | legend columns = 3, | |
| 61 | legend style = { | |
| 62 | at = {(0.5, 1.05)}, | |
| 63 | anchor = north, | |
| 64 | column sep = 1ex, | |
| 65 | }, | |
| 66 | ] | |
| 67 | ||
| 68 | \addplot3[cube] coordinates {(0, 0, 0) (0, 1, 0) (0, 1, 1) }; | |
| 69 | \addplot3[cube] coordinates {(0, 1, 0) (1, 1, 0) }; | |
| 70 | \addplot3[backdata] table[x=x,y=y,z=z] {\datapath/data.csv}; | |
| 71 | \addplot3[backiter] table[x=x,y=y,z=z] {\datapath/log.txt}; | |
| 72 | ||
| 73 | \addplot3[ | |
| 74 | surf, | |
| 75 | mesh/ordering=x varies, | |
| 76 | mesh/cols=32, | |
| 77 | mesh/rows=32, | |
| 78 | surfstyle, | |
| 79 | ] table [ | |
| 80 | x = u, | |
| 81 | z = v, | |
| 82 | y expr = 0.0, | |
| 83 | point meta = \thisrow{value}, | |
| 84 | ] {\datapath/F4.csv}; | |
| 85 | \addplot3[ | |
| 86 | surf, | |
| 87 | mesh/ordering=y varies, | |
| 88 | mesh/cols=32, | |
| 89 | mesh/rows=32, | |
| 90 | surfstyle, | |
| 91 | ] table [ | |
| 92 | x expr = 1.0, | |
| 93 | y = u, | |
| 94 | z = v, | |
| 95 | point meta = \thisrow{value}, | |
| 96 | ] {\datapath/F2.csv}; | |
| 97 | \addplot3[ | |
| 98 | surf, | |
| 99 | mesh/ordering=x varies, | |
| 100 | mesh/cols=32, | |
| 101 | mesh/rows=32, | |
| 102 | surfstyle, | |
| 103 | ] table [ | |
| 104 | x = u, | |
| 105 | y = v, | |
| 106 | z expr = 1.0, | |
| 107 | point meta = \thisrow{value}, | |
| 108 | ] {\datapath/F6.csv}; | |
| 109 | ||
| 110 | % Edges | |
| 111 | \addplot3[cube] coordinates {(0, 0, 0) (1, 0, 0) (1, 0, 1) (0, 0, 1) (0, 0, 0)}; | |
| 112 | \addplot3[cube] coordinates {(0, 0, 1) (0, 1, 1) (1, 1, 1) (1, 0, 1)}; | |
| 113 | \addplot3[cube] coordinates {(1, 0, 0) (1, 1, 0) (1, 1, 1)}; | |
| 114 | ||
| 115 | \addplot3[data,onlyfront] table[x=x,y=y,z=z] {\datapath/data.csv}; | |
| 116 | \addlegendentry{Data} | |
| 117 | ||
| 118 | \addplot3[origin,onlyfront] table[x=x,y=y,z=z] {\datapath/origin.csv}; | |
| 119 | \addlegendentry{Origin} | |
| 120 | ||
| 121 | \addplot3[iter,onlyfront] table[x=x,y=y,z=z] {\datapath/log.txt}; | |
| 122 | \addlegendentry{Iterates} | |
| 123 | \end{axis} | |
| 124 | \end{tikzpicture} | |
| 125 | ||
| 126 | \end{document} |