5

How can I draw opposite arrows on the same curve? The following image shows my aim.

!

  • 1
    an you show us what you got so far in the form of a minimal working example? – Johannes_B Jan 22 '14 at 8:00
  • I am still very new to this. I don't know how to do that at all. I just downloaded pgfplots package today. – Ruzayqat Jan 22 '14 at 8:09
  • Have a look at its manual, there is a good tutorial. – Johannes_B Jan 22 '14 at 8:10
  • I did. But I couldn't find anything related to what I am asking for. Two arrows on the same curve (the curve may have an equation xy-coordinates) – Ruzayqat Jan 22 '14 at 8:11
6

The right way to go here is with the library decorations.markings and to define a style that places both arrows and labels.

This is a possibility (some ideas taken from How to make a figure with moving arrows?):

\documentclass[12pt,a4paper]{article}
\usepackage{tikz}

\usetikzlibrary{decorations.markings,arrows} % arrows for *-* tips

\pgfkeys{/tikz/.cd,
  arrow color/.store in=\arrowcolor,
  arrow color=black,
  arrow tip/.store in=\arrowtip,
  arrow tip=to,
  label 1/.store in=\labone,
  label 1={},
  label 2/.store in=\labtwo,
  label 2={},
}

\tikzset{double arrow/.style args={in #1 and #2}{
   postaction=decorate,
   decoration={
    markings,
    mark=at position #2 with {
      \arrow[\arrowcolor,arrows options]{\arrowtip};
      \node[labels options]{\labtwo};
    },
    mark=at position #1 with {
      \arrowreversed[\arrowcolor,arrows options]{\arrowtip};}
      \node[labels options]{\labone};
      }
  },
  arrows options/.style={
    thick
  },
  labels options/.style={
    above=0.1cm  
  }
}

\begin{document}
\begin{tikzpicture}
\draw[-stealth, very thick](0,0)--(6,0) node[below]{$x$};
\draw[-stealth, very thick](0,0)--(0,5) node[left]{$y$};

\draw[thick,
  arrow tip={stealth},
  double arrow=in 0.2 and 0.8, % places 
  label 1={$-C$},
  label 2={$C$},
  *-*, % tips at both sides of the path
  ] 
 (1,1) node[below] {$z_1$}
 .. controls (3,3) and (5,3) .. 
 (5,3) node[below] {$z_2$};

\end{tikzpicture}
\end{document}

The result:

enter image description here

  • When I performed it actually I got a picture like this but without the two endpoints marks. Any suggestions? – Ruzayqat Jan 22 '14 at 8:45
  • Sorry, my fault :). I updated the first version, but forgetting to add the arrows library and tips. I'll edit the answer. – Claudio Fiandrino Jan 22 '14 at 8:47
4

Another version with tikz v3:

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{decorations.markings,arrows.meta}

\tikzset{
    ->-/.style={decoration={
        markings,
        mark=at position .85 with {\arrow{Latex}}},postaction={decorate}},
    -<-/.style={decoration={
        markings,
        mark=at position .15 with {\arrow{Latex[reversed]}}},postaction={decorate}},
}
\begin{document}
  \begin{tikzpicture}
    \draw (-1,0) -- node[pos=0.1,below] {$O$} (6,0)node[pos=0.98,below] {$x$};
    \draw (0,-1) -- (0,6)node[pos=0.98,left] {$y$};

    \node[inner sep=2pt,circle,fill=black,label={below:$z_{1}$}] at  (1,2) (a) {} ;
    \node[inner sep=2pt,circle,fill=black,label={below:$z_{2}$}] at  (5,3) (b) {} ;
    \draw (a) edge[in=180,out=30,->-,-<-] node[pos=0.1,above]{$-C$} node[pos=0.85,above]{$C$} (b) ;
  \end{tikzpicture}
\end{document}

enter image description here

1

With PSTricks just for fun.

\documentclass[pstricks,border=12pt,12pt]{standalone}
\usepackage{pst-eucl,pstricks-add}

\begin{document}
\begin{pspicture}(-1,-1)(7,4)
    \pstGeonode[PosAngle={-135,-90},PointSymbol={none,default}]{O}(1,1){z_1}(5,3){z_2}
    \psaxes[labels=none,ticks=none](0,0)(-1,-1)(7,4)[$x$,-90][$y$,180]
    \psset{ArrowInside=->,ArrowInsidePos=.8,npos=.8,shortput=nab,arrowscale=1.8}
    \pcarc[arcangle=20](z_1)(z_2)^{$C$}
    \pcarc[arcangle=-20](z_2)(z_1)_{$-C$}
\end{pspicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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