我是 pgfplot 和 latex 自动化的新手。我正在绘制一个 3d 散点图,如附图所示。我想从每个点到底面画一条线(因此 z = 0,x 和 y 是点坐标)。这些点来自 CSV 文件。有没有办法不用手动绘制每条线就可以完成我想要的操作?非常感谢您的帮助。
编辑:这是我的代码,抱歉遗漏了。
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xlabel = x ylabel = y, zlabel = z, title=test, grid=major, grid style = {dashed, gray!30}, ymin=0, ymax=1, ylabel style={rotate=90}]
\addplot3+[only marks] table[col sep=comma] {Results_CSV/F6/data.csv};
\end{axis}
\end{tikzpicture}
\end{document}
以下是一些要点:
54,0.025,0.025
39,0.05,0.05
34,0.075,0.075
32,0.1,0.1
32,0.125,0.125
其中第一、第二和第三行分别是 x、y 和 z 轴。
答案1
欢迎使用 TeX-SE!有人指出这里此处ycomb
有效。全部功劳归于汤姆·邦巴迪尔。飞机只是为了引导视线。
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{filecontents}
\begin{filecontents*}{data.csv}
54,0.025,0.025
39,0.05,0.05
34,0.075,0.075
32,0.1,0.1
32,0.125,0.125
\end{filecontents*}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xlabel = $x$,ylabel = $y$, zlabel = $z$, title=test, grid=major,
grid style = {dashed, gray!30}, enlargelimits=0.2,
ylabel style={rotate=90}]
\fill[red,opacity=0.3]
(\pgfkeysvalueof{/pgfplots/xmin},\pgfkeysvalueof{/pgfplots/ymin},0)
-- (\pgfkeysvalueof{/pgfplots/xmax},\pgfkeysvalueof{/pgfplots/ymin},0)
-- (\pgfkeysvalueof{/pgfplots/xmax},\pgfkeysvalueof{/pgfplots/ymax},0)
-- (\pgfkeysvalueof{/pgfplots/xmin},\pgfkeysvalueof{/pgfplots/ymax},0) -- cycle;
\addplot3+[ycomb] table[col sep=comma,header=false] {data.csv};
\end{axis}
\end{tikzpicture}
\end{document}