![绘制箭头](https://linux22.com/image/376554/%E7%BB%98%E5%88%B6%E7%AE%AD%E5%A4%B4.png)
如何在图表上绘制指向特定点的箭头?我想要一个指向以下代码中内置图表中 (1,1) 的箭头。我发现这个专门用于查看表格单元格,但我无法让它在图表上工作:如何在表格单元格中绘制箭头?
\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
像这样?
只需添加\draw[thick, -Straight Barb] (0.5,1) -- (1,1);
到您的代码中:
\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}