Wed, 06 Nov 2024 21:12:14 -0500
Improve TikZ
\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 }, illustr3d/.style = { axis equal, width=5cm, height=5cm, scale only axis, enlargelimits=false, colormap access=map, colormap/Blues, 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, }, } } \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}; \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}