我想从仅包含 z 数据(按矩阵排列)的文件中绘制网格表面。想法是绘制 z 数据与 x 索引和 y 索引的关系。有没有简单的方法可以做到这一点,还是我必须对数据文件进行预处理?
pgfplots
(我在手册和几个 StackExchange 问题中搜索过,但没有成功。)
虚拟数据示例:
CSV data file `data.txt'
M1,M2,M3,M4
0,0,0,0
3.466,2.058,0,0
4.262,2.976,0.001,0
3.822,3.168,0.006,0.008
2.953,2.936,0.019,0.063
2.065,2.492,0.046,0.265
1.332,1.977,0.092,0.734
0.797,1.478,0.164,1.508
MNWE(用于最小非工作示例^^):
\documentclass{minimal}
\usepackage{pgfplots,pgfplotstable}
\begin{document}
\begin{tikzpicture}
\pgfplotstableread[col sep=comma]{data.txt}\csvdata
\begin{axis}
\addplot3[surf] table[x expr=\coordindex,y expr={SOME COLUMN INDEX?}] {\csvdata};
\end{axis}
\end{tikzpicture}
\end{document}