TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any workaround to use [pos=] or [midway] option in a node following a "plot" to annotate the path? The following minimal example will have the node text missing:

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
    \draw[very thin,color=gray] (-0.1,-0.1) grid (2.9,4.1);
    \draw[->] (-0.2,0) -- (3.2,0) node[right] {$x$};
    \draw[->] (0,-0.2) -- (0,4.2) node[above] {$f(x)$};

    \draw[domain=0:3] plot (\x,{\x^2}) node[midway, sloped] {midway?};
\end{tikzpicture}
\end{document}
share|improve this question
up vote 16 down vote accepted

I forgot decoration

last version

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}

\begin{document}

\begin{tikzpicture}[domain=0:2,label/.style={%
   postaction={ decorate,transform shape,
   decoration={ markings, mark=at position .5 with \node #1;}}}]
\draw[very thin,color=gray] (-0.1,-1.1) grid (3.9,3.9); 

\draw[red,label={[above]{$f(x)=x^2$}}] plot(\x,{\x^2}) ;     

\end{tikzpicture}
\end{document} 

enter image description here

share|improve this answer
    
thanks for your quick answer. Using this, we however lost the nice /tikz/sloped option that puts the label along the path. – YIchun Jun 24 '11 at 17:32
    
@YIchun I forgot the decoration see my new answer – Alain Matthes Jun 24 '11 at 18:24
    
@YIchun Third version :( – Alain Matthes Jun 24 '11 at 18:32
    
@YIchun But I don't like the `sloped' labels ! – Alain Matthes Jun 24 '11 at 18:36
2  
@Chernoff You need only to remove transform shape – Alain Matthes Sep 20 '12 at 4:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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