4

How do I draw snaked curved lines using tikz? What I want is something like this:

enter image description here

I tried to do that using the following code:

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{snakes}

\begin{figure}[h]
    \begin{center}
        \begin{tikzpicture}[scale=1.5]
            \draw[->] (0,0) -- (4,0) node[below] {$\tilde{X}$};
            \draw[->] (0,0) -- (0,4) node[left] {$\tilde{T}$};
            \draw[red, very thick, snake=snake,->] (0,0) -- (3.5,3.5) node[right,black] {$r=2m$};
            \draw[thick ,<->] (3.5,-3.5) -- (-3.5,3.5) node[left] {$r=2m$};


            \draw[blue,bend right=40,thick, dashed] (1.5,1.5) to (1.5,-1.5);
            \draw[blue,bend right=41,thick, dashed] (2.0,2.0) to (2.0,-2.0);
            \draw[blue,bend right=42,thick, dashed] (2.5,2.5) to (2.5,-2.5);
            \draw[blue,bend right=43,thick, dashed] (3.0,3.0) to (3.0,-3.0);
            \draw[blue,bend right=44,thick, dashed] (3.5,3.5) to (3.5,-3.5);
            \draw[red, snake=snake, very thick] (-3,3) to [out= -45, in = 225](3,3);
            %\draw[purple,bend right=40,very thick] (0,0) to (3,0);
           draw[thick] (0,1.78) node[above] {$r=0 $}; 


        \end{tikzpicture}
    \end{center}
\end{figure}

The part where I try to "snake" the red curve is:

\draw[red, snake=snake, very thick] (-3,3) to [out= -45, in = 225](3,3);

But what I got was this:

enter image description here

The snake = snake command worked for the straight line but why wont it work for the curved? how do i fix this?

0

1 Answer 1

3

The snake=snake option is strange (I don't want to know why it is working). The official syntax is decoration,decorate=snake (see p.55, pgfmanual, v3.0.1a).

enter image description here

\documentclass[margin=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{snakes}
\begin{document}
\begin{tikzpicture}[scale=1.5]
  \draw[->] (0,0) -- (4,0) node[below] {$\tilde{X}$};
  \draw[->] (0,0) -- (0,4) node[left] {$\tilde{T}$};
  \draw[red, very thick,->,decorate] (0,0) -- (3.5,3.5) node[right,black] {$r=2m$};
  \draw[thick ,<->] (3.5,-3.5) -- (-3.5,3.5) node[left] {$r=2m$};


  \draw[blue,bend right=40,thick, dashed] (1.5,1.5) to (1.5,-1.5);
  \draw[blue,bend right=41,thick, dashed] (2.0,2.0) to (2.0,-2.0);
  \draw[blue,bend right=42,thick, dashed] (2.5,2.5) to (2.5,-2.5);
  \draw[blue,bend right=43,thick, dashed] (3.0,3.0) to (3.0,-3.0);
  \draw[blue,bend right=44,thick, dashed] (3.5,3.5) to (3.5,-3.5);
  \draw[red,decorate,decoration=snake, very thick] (-2.9,3.1) to [out= -45, in = 225](2.9,3.1);
\end{tikzpicture}
\end{document}

You must log in to answer this question.

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