# HG changeset patch # User Tuomo Valkonen # Date 1730923111 18000 # Node ID 5f2b65738e666198fadb9db632817547f5b82de9 # Parent bd6fd49146cefc23de14b28697fe8ebf08fc9382 Add visualisation TikZ diff -r bd6fd49146ce -r 5f2b65738e66 visualisation/cube.tex --- /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