3

This is my first question in tex.stackexchange. It might be relatively simple problem but I am having difficulties with the placement of the nodes inside graphics.

The problem is that when I try to compile the code below I get the result which has problem.

\documentclass{standalone}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[thick,ticks=none,domain=-pi:pi,samples=1000,axis x line=middle,axis y line=none,xlabel={t},xmin=-4,xmax=7,ymax=2,ymin=-2]
\addplot[smooth, color=black] (\x,{sin((9*(deg(x))) )*cos(((deg(x))) )}) node[pos=0.75,pin={carrier wave},thick,inner sep=0pt] {};
\addplot[smooth, color=black] (\x,{cos(((deg(x))) )}) ;
\addplot[smooth, color=black] (\x,{-cos(((deg(x))) )}) node[pos=0.75,pin={envelope wave},thick,inner sep=0pt] {};
\end{axis}
\end{tikzpicture}

\end{document}

It should look like this (look at the position of the pinned text):

enter image description here

Once it was working but now it is not working.

Mythio
  • 2,204
buraker
  • 39
  • sorry, what do you want to achieve? – d-cmst Apr 03 '13 at 10:18
  • Your code compiles without mishap on my machine. What is your question, exactly? "Once it was working but now it is not working" does not give us much information. – jub0bs Apr 03 '13 at 10:21
  • Welcome to TeX.SX. It is better to turn your code snippet into a MWE starting with \documentclass ending with \end{document} and including only the necessary packages that reproduce the problem. This will help who wants to answer you. :) – Claudio Fiandrino Apr 03 '13 at 10:30
  • you can look at this link http://i45.tinypic.com/wgyus5.png to see the problem I think, I have a compiler options problem. – buraker Apr 03 '13 at 10:42
  • So the problem is that the arrow and carrier wave is not in the correct location? It's important to provide an MWE as @ClaudioFiandrino stated, otherwise we can't determine which options might be interfering with your image. – Mythio Apr 03 '13 at 10:47
  • @Mythio, Here is the problem, http://i46.tinypic.com/b6q5hi.png ,I cannot change the position it always gets the lower left as reference. Changing angle changes the angle but position is fixed. code \addplot[smooth, color=black] (\x,{sin((9(deg(x))) )cos(((deg(x))) )}) node[pos=0.93,pin=85:{carrier wave},thick] {}; \addplot[smooth, color=black] (\x,{cos(((deg(x))) )}) ; \addplot[smooth, color=black] (\x,{-cos(((deg(x))) )}) node[pos=0.52,pin=10:{envelope wave},thick] {}; – buraker Apr 03 '13 at 10:59
  • I think the problem is that the text is not appearing correctly in relation to the image, i.e. not as in the example. I've provided an MWE in your question. Unfortunately, I have no idea whats causing this. – Mythio Apr 03 '13 at 11:44
  • @Mythio I do not understand what causes the problem but if I change the nodes to be on the right of the curve it has no problem \documentclass{standalone} \usepackage{pgfplots}\begin{document} \begin{figure}[ht]\centering\begin{tikzpicture} \begin{axis}[thick,ticks=none,domain=-pi:pi,samples=1000,axis x line=middle,axis y line=none,xlabel={t},xmin=-4,xmax=9,ymax=2,ymin=-2] \addplotsmooth}) node[right]{carier wave}; \addplotsmooth ; \end{axis}\end{tikzpicture} \end{figure}\end{document} – buraker Apr 03 '13 at 15:17

1 Answers1

2

Try this (I just fixed the positions and angles for the pins):

\documentclass{article}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[thick,ticks=none,domain=-pi:pi,samples=1000,axis x line=middle,axis y line=none,xlabel={t},xmin=-4,xmax=7,ymax=2,ymin=-2]
\addplot[smooth, color=black] (\x,{sin((9*(deg(x))) )*cos(((deg(x))) )}) node[pos=0.93,pin={[pin distance=1cm]75:carrier wave},thick,inner sep=0pt] {};
\addplot[smooth, color=black] (\x,{cos(((deg(x))) )}) ;
\addplot[smooth, color=black] (\x,{-cos(((deg(x))) )}) node[pos=0.5,pin={290:envelope wave},thick,inner sep=0pt] {};
\end{axis}
\end{tikzpicture}

\end{document}

enter image description here

Gonzalo Medina
  • 505,128
  • Another option would be to use coordinates instead of nodes and use something like shorten <=\pgflinewidth for the pin edge if one wants to preserve the little space that the node occupies. – Qrrbrbirlbel Apr 03 '13 at 18:04