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.

8
  • sorry, what do you want to achieve?
    – d-cmst
    Commented Apr 3, 2013 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
    Commented Apr 3, 2013 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. :) Commented Apr 3, 2013 at 10:30
  • you can look at this link i45.tinypic.com/wgyus5.png to see the problem I think, I have a compiler options problem.
    – buraker
    Commented Apr 3, 2013 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
    Commented Apr 3, 2013 at 10:47

1 Answer 1

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

1
  • 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. Commented Apr 3, 2013 at 18:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .