1

I don't understand why this problem occurs as I can still compile just fine. I'm trying to re-create a diagram. Everything is okay, save for the arrow in the diagram. I'm using TexStudio and MikTex.

enter image description here

Here is the LaTex code I'm using:

\documentclass[dvipsnames]{article}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{decorations.markings,arrows}
\pgfplotsset{compat=newest}

\def\Point{36.9}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
view={-30}{-30},
axis lines=middle,
zmax=60,
height=12cm,
xtick=\empty,
ytick=\empty,
ztick=\empty
]
\addplot3+[,ytick=\empty,yticklabel=\empty,
mark=none,
thick,
BrickRed,
domain=0:14.7*pi,
samples=400,
samples y=0,
]
({x*sin(0.28*pi*deg(x))},{x*cos(0.28*pi*deg(x)},{x});
\addplot3+[
mark options={color=MidnightBlue},
mark=*
] 
coordinates {({\Point*sin(0.28*pi*deg(\Point))},{\Point*cos(0.28*pi*deg(\Point)},{\Point})};
\addplot3+[
mark=none,
dashed,
domain=0:12*pi,
samples=100,
samples y=0
]  
({\Point*sin(0.28*pi*deg(\Point))},{\Point*cos(0.28*pi*deg(\Point)},{x});
\addplot3[
mark=none,
dashed
]
coordinates {(0,0,0) ({\Point*sin(0.28*pi*deg(\Point))},{\Point*cos(0.28*pi*deg(\Point)},{0})};

\draw[
radius=80,
decoration={
    markings,
    mark= at position 0.99 with {\arrow{latex}}
},
postaction=decorate
] 

(axis cs:0,10,0) arc[start angle=80,end angle=14] (axis cs:14,0,0);
\node at (axis cs:20,0,30) {$P$};
\node at (axis cs:20,17,0) {$\rho$};
\node at (axis cs:24,0,7) {$z$};
\node at (axis cs:7,12,0) {$\phi$};
\end{axis}
\end{tikzpicture}

\end{document}

Thank you in advance.

Troy
  • 13,741
  • why are you expecting \arrow to be defined? Is \vec what you are looking for? – Bordaigorl Oct 18 '16 at 15:41
  • I don't get any errors compiling what you've got, but what is wrong with \draw[-latex] (axis cs:0,10,0) arc (80:14:80); in place of the arrow you have? In fact, even just replacing the decoration with -latex in your code works if you remove the last point (axis cs:14,0,0) from that path. Is there a reason you need that point there? – Emma Oct 18 '16 at 21:18
  • @Bordaigorl@Emma Acctually I'm just trying to recreate what was done here: http://tex.stackexchange.com/questions/133183/draw-spiral-cone-tikz shown by Gonzalo Medina in the first/accepted answer.

    The Thing is I'm trying to recreate the 'arrow-like' arc seen in the link, however when I compile and run, the arc near 'phi' seems to overshoot and not form an arrow.

    Hope this explanation helps.

    – bat_wave Oct 19 '16 at 07:00
  • @Emma Thanks again for helping me out, I couldn't figure out what you were trying to say before, sorry. It works perfectly now. Thanks – bat_wave Oct 26 '16 at 16:21

1 Answers1

1

It's been a while since I looked at this, but I'll give in to demands and try to write an answer based on my comment above. Beware that I'm having trouble recreating the original issue, so I'm not sure if my answer is really right.

The issue here is not with the \arrow command, but with the path the arrow is on:

\draw[
radius=80,
decoration={
    markings,
    mark= at position 0.99 with {\arrow{latex}}
},
postaction=decorate
] 

(axis cs:0,10,0) arc[start angle=80,end angle=14] (axis cs:14,0,0);

This path starts at (0,10), draws an arc, and then jumps (without drawing) to (14,0). When you use the usual -latex option to tell it to put an arrow on the path it tries to put it on the last segment, which is a single point. So not only is the arrow in the wrong place, it also doesn't know which way to go. [Actually, I don't see this behavior with the marking, even with at position 1. I'm not sure why not.] It looks like there was an attempt to fix this by putting the arrow almost at the end of the path, but that doesn't look great either. Since the last point isn't doing anything, the correct fix is probably just to remove it from the path altogether:

\draw[
radius=80,
decoration={
    markings,
    mark= at position 1 with {\arrow{latex}}
},
postaction=decorate
] 

(axis cs:0,10,0) arc[start angle=80,end angle=14];

That's also not great, since it doesn't shorten the arc to make way for the arrow point. Instead, you'd want to use

\draw[radius=80, -latex] (axis cs:0,10,0) arc[start angle=80, endangle=14];

or in a simpler notation

\draw[-latex] (axis cs:0,10,0) arc (80:14:80);

[Actually, it looks to me like you really want to draw a different arc, like

\draw[-latex] (90:10) arc (90:30:10);

which draws a segment of a circle of radius 10 between the y axis (90 degrees) and the dashed line, in the xy-plane of the axis coordinates. It also seems as though the axis cs: before all the coordinates is superfluous since it is the default. ]

Emma
  • 3,453
  • 12
  • 20