Add visualisation TikZ

Wed, 06 Nov 2024 14:58:31 -0500

author
Tuomo Valkonen <tuomov@iki.fi>
date
Wed, 06 Nov 2024 14:58:31 -0500
changeset 21
5f2b65738e66
parent 20
bd6fd49146ce
child 22
cecdde4ff5c9

Add visualisation TikZ

visualisation/cube.tex file | annotate | diff | comparison | revisions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/visualisation/cube.tex	Wed Nov 06 14:58:31 2024 -0500
@@ -0,0 +1,126 @@
+\documentclass[tikz]{standalone}
+\usepackage{pgfplots}
+\usepackage{tikz-3dplot}
+\usepgfplotslibrary{colorbrewer}
+
+\def\datapath{../res/}
+
+\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}
+
+\pgfplotsset{
+    % forget plot = no legend
+    cube/.style = {thick, gray!50!black,forget plot},
+    iter/.style = {mark=x, red},
+    data/.style = {mark=*, blue, only marks},
+    backdata/.style = {mark=*, blue!30!white, only marks, onlyback, forget plot},
+    backiter/.style = {mark=x, red!30!white, onlyback, forget plot},
+    origin/.style = {mark=o, green, only marks, thick},
+    surfstyle/.style = {very nearly opaque, forget plot},
+    onlyfront/.code = \pgfplotsset{x filter/.code={\onlyfront{\thisrow{face}}}},
+    onlyback/.code = \pgfplotsset{x filter/.code={\onlyback{\thisrow{face}}}},
+    legend style = {
+        inner sep = 0pt,
+        outer xsep = 5pt,
+        outer ysep = 0pt,
+        legend cell align = left,
+        align = left,
+        draw = none,
+        fill = none,
+        font = \small
+    },
+}
+
+\begin{tikzpicture}
+    \begin{axis}[
+        colormap access=map,
+        colormap/Blues,%RdPu-6,
+        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.05)},
+            anchor = north,
+            column sep = 1ex,
+        },
+    ]
+
+        \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};
+        \addplot3[backiter] table[x=x,y=y,z=z] {\datapath/log.txt};
+
+        \addplot3[
+            surf,
+            mesh/ordering=x varies,
+            mesh/cols=32,
+            mesh/rows=32,
+            surfstyle,
+        ] table [
+            x = u,
+            z = v,
+            y expr = 0.0,
+            point meta = \thisrow{value},
+         ] {\datapath/F4.csv};
+        \addplot3[
+            surf,
+            mesh/ordering=y varies,
+            mesh/cols=32,
+            mesh/rows=32,
+            surfstyle,
+        ] table [
+            x expr = 1.0,
+            y = u,
+            z = v,
+            point meta = \thisrow{value},
+         ] {\datapath/F2.csv};
+        \addplot3[
+            surf,
+            mesh/ordering=x varies,
+            mesh/cols=32,
+            mesh/rows=32,
+            surfstyle,
+        ] table [
+            x = u,
+            y = v,
+            z expr = 1.0,
+            point meta = \thisrow{value},
+        ] {\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[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}
+
+        \addplot3[iter,onlyfront] table[x=x,y=y,z=z] {\datapath/log.txt};
+        \addlegendentry{Iterates}
+    \end{axis}
+\end{tikzpicture}
+
+\end{document}
\ No newline at end of file

mercurial