3

I want to draw a 3D cone over some particular point of the scatterplot. So the picture will look like below:

enter image description here

I have looked into the pgfplot documentation for 3D cone drawing but could not find much. Any help is highly appreciated.

4

Taking the code from Tom's answer for your previous question, this may be a starting point:

\documentclass[tikz, border=2mm]{standalone}
\usepackage{pgfplotstable}
\pgfplotsset{compat=1.12}
\usepackage{filecontents}
\begin{filecontents*}{s.dat}
x   y   m
1   2   3
2   1   4
1   1   2
2   2   1
\end{filecontents*}

\begin{document}

\begin{tikzpicture}
\begin{axis}
[   view={120}{40},
    xmin=0,xmax=3,
    ymin=0,ymax=3,
    zmin=0, zmax=5,
]
    \addplot3[only marks, ycomb, scatter, mark=cube*, mark size=3,
        point meta=explicit, z filter/.code={\pgfmathparse{0}\pgfmathresult},
] table[meta=m] {s.dat};
    \addplot3[mark=none, ycomb] table {s.dat};
\end{axis}
\begin{axis}[
hide axis,
domain=0:1,
y domain=0:-2*pi,
xmin=-1.5, xmax=1.5,
ymin=-1.5, ymax=1.5, zmin=-1.2,
samples=10,
samples y=40,
z buffer=sort,
]
\addplot3[mesh]
({1.1*x*cos(deg(y))},{1.1*x*sin(deg(y))},{-x});
\end{axis}
\end{tikzpicture}

\end{document}

enter image description here

With only scatter plot:

\documentclass[tikz, border=2mm]{standalone}
\usepackage{pgfplotstable}
\pgfplotsset{compat=1.12}
\usepackage{filecontents}
\begin{filecontents*}{s.dat}
x   y   m
1   2   3
2   1   4
1   1   2
2   2   1
\end{filecontents*}

\begin{document}

\begin{tikzpicture}
\begin{axis}
[   view={120}{40},
    xmin=0,xmax=3,
    ymin=0,ymax=3,
    zmin=0, zmax=5,
]
    \addplot3[only marks, scatter, mark=*, mark size=3,
        point meta=explicit, z filter/.code={\pgfmathparse{0}\pgfmathresult},
] table[meta=m] {s.dat};    
\end{axis}
\begin{axis}[
hide axis,
domain=0:1,
y domain=0:-2*pi,
xmin=-1.5, xmax=1.5,
ymin=-1.5, ymax=1.5, zmin=-1.2,
samples=10,
samples y=40,
z buffer=sort,
]
\addplot3[mesh,olive]
({1.1*x*cos(deg(y))},{1.1*x*sin(deg(y))},{-x});
\end{axis}
\end{tikzpicture}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.