Graphics, Figures & Tablesbeamer | tikZ Arrows

Information and discussion about graphics, figures & tables in LaTeX documents.
latexhelp1
Posts: 141
Joined: Sun Jun 12, 2011 6:30 am

beamer | tikZ Arrows

Post by latexhelp1 »

How do you get an arrow in Tikz to be diagonal (picture a curve like y = -x but pointing downward)?

Right now I can only get it to be vertical.

I'm using for code:

Code: Select all

\frame
{
 \frametitle{Slide Title}
    \begin{tikzpicture}
     [/tikz/every pin edge/.style = <-, scale=1.0]
      \begin{axis}
         axis x line  = bottom,
         axis y line  = left,
         width        = 1.01\textwidth,
         height       = .63\textwidth,          % Adjusted
         legend style = { at = {(1.00,0.30)}, draw = none },
         xlabel       = Year,
         ylabel       = Percent,
         ymax         = 93,
         ymin         = 27,
         ytick        = {30,40,...,90},
         xmax         = 1993,
         xmin         = 1967,
         xtick        = {1970, 1980, ..., 1990},
       ]
              \node[coordinate, pin = 90:
        ] at (axis cs:1985,75) { };
       
      \end{axis}
   \end{tikzpicture}
} 

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

beamer | tikZ Arrows

Post by Stefan Kottwitz »

There are many possibilities.

Code: Select all

\begin{tikzpicture}
  \coordinate (A);
  \node[below right of=A,coordinate] (B) {};
  \draw[->] (A) -- (B);
\end{tikzpicture}
Stefan
LaTeX.org admin
latexhelp1
Posts: 141
Joined: Sun Jun 12, 2011 6:30 am

beamer | tikZ Arrows

Post by latexhelp1 »

Thank you for sending this code over! I don't quite understand how to implement it, however. Suppose that I'd like the arrow to go from (1980, 80) to (1985, 75). And I want to embed that in the plot that I already have.

Is that?

Code: Select all

\begin{tikzpicture}
  \coordinate (1980, 80);
  \node[below right of=(1980, 80),coordinate] (1985, 75) {};
  \draw[->] (1980, 80) -- (1985, 75);
\end{tikzpicture}
That doesn't seem to compile, so I'm not sure.....
Stefan_K wrote:There are many possibilities.

Code: Select all

\begin{tikzpicture}
  \coordinate (A);
  \node[below right of=A,coordinate] (B) {};
  \draw[->] (A) -- (B);
\end{tikzpicture}
Stefan
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

beamer | tikZ Arrows

Post by Stefan Kottwitz »

It was just an arbitrary example answering the question:
latexhelp1 wrote:How do you get an arrow in Tikz to be diagonal (picture a curve like y = -x but pointing downward)?
I did not refer to your code, simply because your code is not compilable and you did not mention which library or package you used. It doesn't even work when I tried it with pgfplots. Earlier, you posted small compilable examples when you showed a problem, now it requires every reader who would like to practically help to create a test example on his own for simulating the problem, and this even without sufficient information about involved packages and settings.

Stefan
LaTeX.org admin
latexhelp1
Posts: 141
Joined: Sun Jun 12, 2011 6:30 am

beamer | tikZ Arrows

Post by latexhelp1 »

Dear Stefan,

My deepest apologies. I hope you will please accept this code as a minimal working example.

Code: Select all

\documentclass[professionalfont, fleqn]{beamer}
\mode<presentation>
\usetheme{Warsaw}
\usetheme{CambridgeUS}

\usepackage{pgfplots}
\usetikzlibrary{arrows,shapes,positioning}
\graphicspath{{graphics/}}

\begin{document}
\frame
{
 \frametitle{Frame Title}
     \begin{tikzpicture}
      \begin{axis}
       [
         axis x line  = bottom,
         axis y line  = left,
         width        = 1.01\textwidth,
         height       = .63\textwidth,          % Adjusted
         ymax         = 93,
         ymin         = 27,
         ytick        = {30,40,...,90},
         xmax         = 1993,
         xmin         = 1967,
         xtick        = {1970, 1980, ..., 1990},
       ]
       \node[anchor=west] at (axis cs:1968.5,89.5){%
       \textbullet\ Comment here about data
       };
      \end{axis}
   \end{tikzpicture}
} 

\end{document}
I would like to draw an arrow from the word data, which is approximately the coordinate (1982, 88) and have it point to say (1985, 82).

I would very much appreciate any help!
Stefan_K wrote:It was just an arbitrary example answering the question:
latexhelp1 wrote:How do you get an arrow in Tikz to be diagonal (picture a curve like y = -x but pointing downward)?
I did not refer to your code, simply because your code is not compilable and you did not mention which library or package you used. It doesn't even work when I tried it with pgfplots. Earlier, you posted small compilable examples when you showed a problem, now it requires every reader who would like to practically help to create a test example on his own for simulating the problem, and this even without sufficient information about involved packages and settings.

Stefan
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

beamer | tikZ Arrows

Post by Stefan Kottwitz »

With a complete example, it's no problem.

Just add

Code: Select all

\draw[->] (axis cs:1982, 88) -- (axis cs:1985, 82);
before \end{axis}, or use any other coordinate you like.

Stefan
LaTeX.org admin
latexhelp1
Posts: 141
Joined: Sun Jun 12, 2011 6:30 am

beamer | tikZ Arrows

Post by latexhelp1 »

Thank you!

How can I make the arrow head thicker? (I feel like I can hardly see the arrow head.)

Also, how could I make the arrow circular? For example, an arrow that goes from say 9 oclock to 12 oclock or 9 oclock to 6 oclock.
Stefan_K wrote:With a complete example, it's no problem.

Just add

Code: Select all

\draw[->] (axis cs:1982, 88) -- (axis cs:1985, 82);
before \end{axis}, or use any other coordinate you like.

Stefan
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

beamer | tikZ Arrows

Post by Stefan Kottwitz »

For making the complete arrow thicker:

Code: Select all

\draw[->, thick] (axis cs:1982, 88) -- (axis cs:1985, 82);
and

Code: Select all

\draw[->, very thick] (axis cs:1982, 88) -- (axis cs:1985, 82);
For another and better visible arrowhead, use any other of the arrows library, such as

Code: Select all

\draw[->,-triangle 60] (axis cs:1982, 88) -- (axis cs:1985, 82);
Stefan
LaTeX.org admin
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

beamer | tikZ Arrows

Post by Stefan Kottwitz »

Here's how you can make a bend arrow:

Code: Select all

\draw[->,-triangle 60] (axis cs:1982, 88) to[bend right=-60] (axis cs:1985, 82);
and in the other direction

Code: Select all

\draw[->,-triangle 60] (axis cs:1982, 88) to[bend right=60] (axis cs:1985, 82);
Stefan
LaTeX.org admin
latexhelp1
Posts: 141
Joined: Sun Jun 12, 2011 6:30 am

beamer | tikZ Arrows

Post by latexhelp1 »

Thank you Stefan for the continued help! Is there a way to make the arrow as a circle to instead an oval? That is, the arrow (right = -60) rises much higher than I'd like. Thus, I'm wondering how I can make it lower, and curve like an oval. Is that possible?
Stefan_K wrote:Here's how you can make a bend arrow:

Code: Select all

\draw[->,-triangle 60] (axis cs:1982, 88) to[bend right=-60] (axis cs:1985, 82);
and in the other direction

Code: Select all

\draw[->,-triangle 60] (axis cs:1982, 88) to[bend right=60] (axis cs:1985, 82);
Stefan
Post Reply