我希望根据文件 data.txt 中提供的轮廓坐标绘制 3D 表面。以下代码按预期工作。
\usepackage{pgfplots}
\pgfplotsset{compat = newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[view={0}{160},
xlabel={$x$},
ylabel={$y$},
zlabel={$z$}]
\addplot3[green, fill] table[x={X}, y={Y} , z={Z}] {data.txt};
\end{axis}
\end{tikzpicture}
\end{document}
其结果是:
现在我想用非常量颜色进行填充。具体来说,我想用渐变进行填充,其中颜色由数据的 y 值决定。如何实现?
为了完整起见,这是 data.txt 文件:
X Y Z
1.0 0.23750000000000004 0
0.9500000000000001 0.23756250000000004 0
0.9 0.23850000000000005 0
0.8500000000000001 0.24256250000000004 0
0.8 0.25350000000000006 0
0.75 0.27656250000000004 0
0.7000000000000001 0.3185 0
0.65 0.38756250000000003 0
0.6000000000000001 0.4934999999999998 0
0.55 0.6475624999999999 0
0.5 0.8625 0
0.45 0.6600000000000001 0
0.4 0.5025000000000001 0
0.35000000000000003 0.39000000000000007 0
0.30000000000000004 0.3225 0
0.25 0.3 0
0.2 0.32249999999999995 0
0.15000000000000002 0.38999999999999996 0
0.1 0.5025 0
0.05 0.6600000000000001 0
0.0 0.8625 0
0.05 0.6600000000000001 0.1
0.1 0.5025 0.2
0.15000000000000002 0.38999999999999996 0.30000000000000004
0.2 0.32249999999999995 0.4
0.25 0.3 0.5
0.30000000000000004 0.3225 0.6000000000000001
0.35000000000000003 0.39000000000000007 0.7000000000000001
0.4 0.5025000000000001 0.8
0.45 0.6600000000000001 0.9
0.5 0.8625 1.0
0.55 0.6475624999999999 0.9000000000000001
0.6000000000000001 0.4934999999999998 0.8
0.65 0.38756250000000003 0.7000000000000002
0.7000000000000001 0.3185 0.6000000000000001
0.75 0.27656250000000004 0.5
0.8 0.25350000000000006 0.40000000000000013
0.8500000000000001 0.24256250000000004 0.30000000000000004
0.9 0.23850000000000005 0.20000000000000018
0.9500000000000001 0.23756250000000004 0.10000000000000009
1.0 0.23750000000000004 0.0
答案1
您可能只想在更好的图像程序中制作图形,然后截取最终结果的屏幕截图并将\includegraphics
其放入您的 TeX 文件中。