I'm trying to combine two different suggestions people made about an earlier question I asked. I'm getting a bunch of errors, but I'm not sure what the problem is. The code is:
\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\def\mycurve#1{(0,0) to[out=70, in=180] (5,1.8)#1}
\begin{document}
\begin{tikzpicture}
\clip (-0.1,-0.1) rectangle (5,3);
\draw[help lines,->] (0,0) -- (4.2,0);
\draw[help lines,->] (0,0) -- (0,3); % draw axis lines
\draw[gray,dashed] (0,2) -- (4.2,2); % draw asymptote
\draw[domain=0.5:4.6,very thick,red,->,samples=400] \mycurve;% draw plot
\foreach \x in {0.25,0.5,...,4}
{
\draw[help lines,->] (\x,0) -- ($(\x,\mycurve)-(0,0.6pt)$);
}
\end{tikzpicture}
\end{document}
I think the problem is at the end, where I try to make the vertical lines relative to the curve; it works if the curve is defined as a hyperbola, as in \def\mycurve#1{{1/(-(\x+#1))+2}}, but if I define an arbitrary curve it doesn't. Can I not do that, or did I make a code mistake somewhere?
\mycurvewith an argument, but don't supply one, so#1becomes the closing parenthesis), messing everything up. – egreg Jun 24 '14 at 14:46\mycurve)...here TeX will think)is your argument and TikZ will not find the closing parens – Bordaigorl Jun 24 '14 at 14:46\mycurve;is problematic too – Bordaigorl Jun 24 '14 at 14:47$(\x,(0,0) to[out=70, in=180] (5,1.8))-(0,0.6pt)$)is not legal. – egreg Jun 24 '14 at 14:54\mycurvedoes not define a "curve", but rather a numerical function of\xand an arbitrary argument. This numerical function can be understood by\drawfor a plot, and in a coordinate definition (if there is a\xin the context). But indeed you cannot replace it with an "arbitrary curve" which will not make sense in either of these contexts. – T. Verron Jun 24 '14 at 14:59(0,0) to[out=70, in=180] (5,1.8)or define the vertical arrows in relation to the curve, but I can't do both. Is that right? – crmdgn Jun 24 '14 at 15:22