I have created a tikz plot for which I would now like to plot arrows on to show direction of flow. The current code used is:

        \draw[thick, ->] (0, -3) -- (0, 3) node [black, anchor=south] {$y$};
        \draw[thick, ->] (-3, 0) -- (3, 0) node [black, anchor=west] {$x$};
        \draw[scale=1,domain=0.33:3,smooth,variable=\x,black, thick] plot ({\x},{1/\x});
        \draw[scale=1,domain=-3:-0.33,smooth,variable=\x,black, thick] plot ({\x},{1/\x});
        \draw[scale=1,domain=0.33:3,smooth,variable=\x,black, thick] plot ({\x},{-1/\x});
        \draw[scale=1,domain=-3:-0.33,smooth,variable=\x,black, thick] plot ({\x},{-1/\x});

Which produces the image

enter image description here

Now I want to add arrows onto each line separately. I require the direction of the arrow to be given by me (in the case I would like to use this in another example. They should occur at approximately half way through the curve. An example:

enter image description here


Something like this?

enter image description here

    mark=at position 0.25 with {\arrow[blue,very thick]{>}},
    mark=at position 0.75 with {\arrowreversed[blue,very thick]{>}}}
\draw[postaction={decorate},thick,->] (0, -3) -- (0,3) node [black,above] {$y$};
    mark=at position 0.25 with {\arrowreversed[blue,very thick]{>}},
    mark=at position 0.75 with {\arrow[blue,very thick]{>}}}
\draw[postaction={decorate},thick,->] (-3, 0) -- (3,0) node [black,right] {$x$};
    mark=at position 22mm with {\arrow[red,very thick]{>}}}
\draw[postaction={decorate},thick] plot[domain=0.33:3]      (\x,{1/\x});
\draw[postaction={decorate},thick] plot[domain=-0.33:-3]    ({\x},{1/\x});
\draw[postaction={decorate},thick] plot[domain=0.33:3]      (\x,{-1/\x});
\draw[postaction={decorate},thick] plot[domain=-0.33:-3]    (\x,{-1/\x});

Edit: In the first try I didn't care for arrows direction yet nor add them to the coordinate axis. Now this is corrected. To obtain different direction of arrows, I define decorations in scope separate for each coordinate axis and separate for curves. For them I reverse domains for two of them, that the arrows have right direction.

| improve this answer | |
  • The arrow directions are incorrect in the second and third quadrants, also I want arrows on the axes too. Looks good so far though! – user2850514 Nov 18 '15 at 20:24
  • I now, I correct this in edit of my answer. But anyway, you see a wayy, hoe to obtain arrows ... :-) – Zarko Nov 18 '15 at 20:28
  • Awesome, thank you for the effort - exactly what I wanted! – user2850514 Nov 18 '15 at 20:35

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.