2

How can I draw an arrow to a specific point on a chart? I'd like an arrow pointing to (1,1) in the chart built in the code below. I found this that specifically looks at a table cell, but I can't get it working for a chart: How to draw an arrow to a table cell?

\documentclass{article}
\RequirePackage{pgfplots}
\begin{document}
\begin{tikzpicture}[scale=3]
\shade[top color=red,bottom color=gray!50] (0,0) parabola (1.5,2.25) |- (0,0);
    \draw[help lines] (0,0) grid (3.9,3.9) [step=0.25cm];
    \draw[->] (-0.2,0) -- (4,0) node[right] {$x$};
    \draw[->] (0,-0.2) -- (0,4) node[above] {$f(x)$};
    \foreach \x/\xtext in {1/1, 1.5/1\frac{1}{2}, 2/2, 3/3}
    \draw[shift={(\x,0)}] (0pt,2pt) -- (0pt,-2pt) node[below] {$\xtext$};
    \foreach \y/\ytext in {1/1, 2/2, 2.25/2\frac{1}{4}, 3/3}
    \draw[shift={(0,\y)}] (2pt,0pt) -- (-2pt,0pt) node[left] {$\ytext$};
    \draw (-.5,.25) parabola bend (0,0) (2,4) node[below right] {$x^2$};
\end{tikzpicture}

\end{document}

1 Answer 1

2

like this?

enter image description here

just add \draw[thick, -Straight Barb] (0.5,1) -- (1,1); to your code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta} % added

\begin{document}
\begin{tikzpicture}[scale=3]
\shade[top color=red,bottom color=gray!50] (0,0) parabola (1.5,2.25) |- (0,0);
    \draw[help lines] (0,0) grid (3.9,3.9) [step=0.25cm];
    \draw[->] (-0.2,0) -- (4,0) node[right] {$x$};
    \draw[->] (0,-0.2) -- (0,4) node[above] {$f(x)$};
    \foreach \x/\xtext in {1/1, 1.5/1\frac{1}{2}, 2/2, 3/3}
    \draw[shift={(\x,0)}] (0pt,2pt) -- (0pt,-2pt) node[below] {$\xtext$};
    \foreach \y/\ytext in {1/1, 2/2, 2.25/2\frac{1}{4}, 3/3}
    \draw[shift={(0,\y)}] (2pt,0pt) -- (-2pt,0pt) node[left] {$\ytext$};
    \draw (-.5,.25) parabola bend (0,0) (2,4) node[below right] {$x^2$};
\draw[thick, -Straight Barb] (0.5,1) -- (1,1);     %added
\end{tikzpicture}
\end{document}

You must log in to answer this question.

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