3

I would like to plot circle (or another curve) with positive direction (and show it wit arrows).

This plots the circle

\documentclass{article}
\usepackage{tikz}
\RequirePackage{pgfplots}
\usetikzlibrary{shadows}
\usetikzlibrary{shapes}
\usetikzlibrary{decorations}
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
            xmin=-1.5,xmax=2.5,ymin=-1.5,ymax=1.5,
            axis lines=center,
            ticks=none,
            unit vector ratio*=1 1 1,
           ]        
          \addplot [very thick, smooth, domain=(0:2*pi)] ({1.+cos(deg(x))},{sin(deg(x))});

      \addplot[only marks,mark=*] coordinates{(1,0)};
        \end{axis}
\end{tikzpicture}
\end{document}

And I want to add arrows like that

example image

Would you advise me how to add such arrows?

3

2 Answers 2

6

This is your code with the addition of arrows and decorations.markings tikzlibraries plus a tikz style (redarrows.tikstyle) where the arrow heads are defined. The code lets you easily customize the color and the shape af the arrowheads. I used >, but if you like another style refer to the list contained in Is it possible to change the size of an arrowhead in TikZ/PGF? and just change the argument of \arrow inside the tikz style

\documentclass{article}

\usepackage{tikz}
\RequirePackage{pgfplots}
\usetikzlibrary{shadows}
\usetikzlibrary{shapes}
\usetikzlibrary{decorations}
\usetikzlibrary{arrows,decorations.markings}         %new code

\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}

\setlength\PreviewBorder{5pt}

\begin{document}   
\tikzset{               %new code
    redarrows/.style={postaction={decorate},decoration={markings,mark=at position 0.1 with {\arrow[draw=red]{>}}},
           decoration={markings,mark=at position -0.4 with {\arrow[draw=red]{>}}},}}
\begin{tikzpicture}
    \begin{axis}[
            xmin=-1.5,xmax=2.5,ymin=-1.5,ymax=1.5,
            axis lines=center,
            ticks=none,
            unit vector ratio*=1 1 1,
           ]        
          \addplot [very thick, smooth, domain=(0:2*pi),redarrows] ({1.+cos(deg(x))},{sin(deg(x))});         %new code

      \addplot[only marks,mark=*] coordinates{(1,0)};
        \end{axis}
\end{tikzpicture}

\end{document}

enter image description here

3
  • is it possible to place the arrows based on polar coordinates like 1) at (radius of circle, angle=45) and 2) at (radius of circle, angle=225) so that position of arrows does not get effected when radius increases ? Apr 16, 2013 at 8:30
  • It's possible that I'm completely missing your point, but if you draw the first arrow at position, say, 0.125, no matter how bigger or smaller the circle is the arrow will always point to the corresponding angle.
    – d-cmst
    Apr 16, 2013 at 9:42
  • What do the marking positions actually mean? I can't get more than 2 arrows to appear on my curve, the rest of them just go to random places
    – nog642
    Dec 12, 2022 at 12:11
2

With PSTricks.

enter image description here

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}
\begin{document}
\begin{pspicture}(-1,-3)(5,3)
    \psaxes[labels=none,ticks=none,linecolor=gray](0,0)(-1,-3)(5,3)
    \pscircle[dimen=middle](2.5,0){2}
    \psset{arrows=->,arrowinset=0,arcsep=-1.5\pslinewidth,linecolor=red}
    \psarc(2.5,0){2}{44}{46}
    \psarc(2.5,0){2}{-136}{-134}
\end{pspicture}
\end{document}

Warning:

I don't know how to change the arrow head color more elegantly.

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