--- a/visualisation/cube.tex Thu Nov 07 16:52:05 2024 -0500 +++ b/visualisation/cube.tex Wed Dec 04 23:19:46 2024 -0500 @@ -1,93 +1,39 @@ \documentclass[tikz]{standalone} -\usepackage{pgfplots} -\usepackage{tikz-3dplot} -\usepackage[svgnames]{xcolor} -\usepgfplotslibrary{colorbrewer} -\def\datapath{../res/} +\input{plotsetup} + +\def\datapath{../res/cube} \begin{document} -\tdplotsetmaincoords{50}{25} - -\def\onlyfront#1{ - \ifnum#1=2\else\ifnum#1=4\else\ifnum#1=6\else - \def\pgfmathresult{} - \fi\fi\fi} - -\def\onlyback#1{ - \ifnum#1=1\else\ifnum#1=3\else\ifnum#1=5\else - \def\pgfmathresult{} - \fi\fi\fi} +\begin{tikzpicture} + \pgfplotsset{ + onlyfront/.code = \pgfplotsset{x filter/.expression={% + or(\thisrow{face} == 2, or(\thisrow{face} == 4, \thisrow{face} == 6)) ? x : nan% + },}, + onlyback/.code = \pgfplotsset{x filter/.expression={% + or(\thisrow{face} == 1, or(\thisrow{face} == 3, \thisrow{face} == 5)) ? x : nan% + },}, + } + + \begin{axis}[illustr3d] + % Hidden edges + \addplot3[edge] coordinates {(0, 0, 0) (0, 1, 0) (0, 1, 1) }; + \addplot3[edge] coordinates {(0, 1, 0) (1, 1, 0) }; -\pgfplotsset{ - % forget plot = no legend - cube/.style = {thick, gray!50!black,forget plot}, - onlyfront/.code = \pgfplotsset{x filter/.code={\onlyfront{\thisrow{face}}}}, - onlyback/.code = \pgfplotsset{x filter/.code={\onlyback{\thisrow{face}}}}, - data/.style = {mark=*, blue, only marks}, - backdata/.style = {mark=*, blue!30!white, only marks, onlyback, forget plot}, - iter1/.style = {mark=x, red}, - iter2/.style = {mark=star, BlueViolet}, - iter3/.style = {mark=asterisk, purple}, - backiter1/.style = {mark=x, red!30!white, onlyback, forget plot}, - backiter2/.style = {mark=star, BlueViolet!30!white, onlyback, forget plot}, - backiter3/.style = {mark=asterisk, purple!30!white, onlyback, forget plot}, - origin/.style = {mark=o, green, only marks, thick}, - surfstyle/.style = {very nearly opaque, forget plot}, - legend style = { - inner sep = 0pt, - outer xsep = 5pt, - outer ysep = 0pt, - legend cell align = left, - align = left, - draw = none, - fill = none, - font = \small - }, - illustr3d/.style = { - axis equal, - width=5cm, - height=5cm, - scale only axis, - enlargelimits=false, - colormap access=map, - colormap/Paired, - colorbar, - point meta rel=axis wide, - shader = interp, - xlabel = {$x$}, - ylabel = {$y$}, - zlabel = {$z$}, - ticks = none, - axis line style = {draw=none}, - %axis x line = none, - %axis y line = none, - %axis z line = none, - legend columns = 3, - legend style = { - at = {(0.5, 1.1)}, - anchor = north, - column sep = 1ex, - }, - mark size=1.5pt, - } -} + % Data on hidden faces + \addplot3[backdata] table[x=x,y=y,z=z] {\datapath/data.csv}; -\begin{tikzpicture} - \begin{axis}[illustr3d] - \addplot3[cube] coordinates {(0, 0, 0) (0, 1, 0) (0, 1, 1) }; - \addplot3[cube] coordinates {(0, 1, 0) (1, 1, 0) }; - \addplot3[backdata] table[x=x,y=y,z=z] {\datapath/data.csv}; + % Iterates on hidden faces \addplot3[backiter1] table[x=x,y=y,z=z] {\datapath/x1_log.csv}; \addplot3[backiter2] table[x=x,y=y,z=z] {\datapath/x2_log.csv}; \addplot3[backiter3] table[x=x,y=y,z=z] {\datapath/x3_log.csv}; + % Surface \addplot3[ surf, - mesh/ordering=x varies, - mesh/cols=32, - mesh/rows=32, + mesh/ordering=x varies, % the second input coordinate stays fixed while first varies + mesh/cols=32, % number of first input coordinate points untils second changes surfstyle, ] table [ x = u, @@ -97,9 +43,8 @@ ] {\datapath/F4.csv}; \addplot3[ surf, - mesh/ordering=y varies, - mesh/cols=32, - mesh/rows=32, + mesh/ordering=x varies, % the second input coordinate stays fixed while first varies + mesh/cols=32, % number of first input coordinate points untils second changes surfstyle, ] table [ x expr = 1.0, @@ -109,9 +54,8 @@ ] {\datapath/F2.csv}; \addplot3[ surf, - mesh/ordering=x varies, - mesh/cols=32, - mesh/rows=32, + mesh/ordering=x varies, % the second input coordinate stays fixed while first varies + mesh/cols=32, % number of first input coordinate points untils second changes surfstyle, ] table [ x = u, @@ -121,16 +65,18 @@ ] {\datapath/F6.csv}; % Edges - \addplot3[cube] coordinates {(0, 0, 0) (1, 0, 0) (1, 0, 1) (0, 0, 1) (0, 0, 0)}; - \addplot3[cube] coordinates {(0, 0, 1) (0, 1, 1) (1, 1, 1) (1, 0, 1)}; - \addplot3[cube] coordinates {(1, 0, 0) (1, 1, 0) (1, 1, 1)}; + \addplot3[edge] coordinates {(0, 0, 0) (1, 0, 0) (1, 0, 1) (0, 0, 1) (0, 0, 0)}; + \addplot3[edge] coordinates {(0, 0, 1) (0, 1, 1) (1, 1, 1) (1, 0, 1)}; + \addplot3[edge] coordinates {(1, 0, 0) (1, 1, 0) (1, 1, 1)}; + % Data \addplot3[data,onlyfront] table[x=x,y=y,z=z] {\datapath/data.csv}; \addlegendentry{Data} \addplot3[origin,onlyfront] table[x=x,y=y,z=z] {\datapath/origin.csv}; \addlegendentry{Origin} + % Iterates \addplot3[iter1,onlyfront] table[x=x,y=y,z=z] {\datapath/x1_log.csv}; \addlegendentry{Iterates 1} \addplot3[iter2,onlyfront] table[x=x,y=y,z=z] {\datapath/x2_log.csv}; @@ -140,4 +86,4 @@ \end{axis} \end{tikzpicture} -\end{document} \ No newline at end of file +\end{document}