我的 tikz 图片中有几个箭头指向同一个坐标。箭头看起来很丑。我想分别看到每个箭头。我该如何改善我的图片?
截屏
代码
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=\linewidth/10cm]
% Help Lines
\draw[step=1,help lines,black!20] (-4.95,-2.95) grid (4.95,3.95);
% Ellipse
\draw[thick] (-2.5,0) ellipse [x radius=1.75, y radius=3];
\draw[thick] (2.5,0) ellipse [x radius=1.75, y radius=3];
% Text
\draw (-2.5,2) node (a) {-4};
\draw (-2.5,1) node (b) {-1,5};
\draw (-2.5,0) node (c) {0};
\draw (-2.5,-1) node (d) {3};
\draw (-2.5,-2) node (e) {7,25};
\draw (2.5,0) node (f) {3};
% Arrow
\draw[thick,->] (a) -- (f);
\draw[thick,->] (b) -- (f);
\draw[thick,->] (c) -- (f);
\draw[thick,->] (d) -- (f);
\draw[thick,->] (e) -- (f);
\end{tikzpicture}
\end{document}
答案1
三种不同的建议。i)缩短箭头,ii)改变端点,iii)弯曲箭头。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[
scale=\linewidth/10cm,
myArrow/.style={thick,->,shorten >=10pt}]
% Help Lines
\draw[step=1,help lines,black!20] (-4.95,-2.95) grid (4.95,3.95);
% Ellipse
\draw[thick] (-2.5,0) ellipse [x radius=1.75, y radius=3];
\draw[thick] (2.5,0) ellipse [x radius=1.75, y radius=3];
% Text
\draw (-2.5,2) node (a) {-4};
\draw (-2.5,1) node (b) {-1,5};
\draw (-2.5,0) node (c) {0};
\draw (-2.5,-1) node (d) {3};
\draw (-2.5,-2) node (e) {7,25};
\draw (2.5,0) node (f) {3};
% Arrow
\draw[myArrow] (a) -- (f);
\draw[myArrow] (b) -- (f);
\draw[myArrow] (c) -- (f);
\draw[myArrow] (d) -- (f);
\draw[myArrow] (e) -- (f);
\end{tikzpicture}
\begin{tikzpicture}[
scale=\linewidth/10cm,
myArrow/.style={thick,->}]
% Help Lines
\draw[step=1,help lines,black!20] (-4.95,-2.95) grid (4.95,3.95);
% Ellipse
\draw[thick] (-2.5,0) ellipse [x radius=1.75, y radius=3];
\draw[thick] (2.5,0) ellipse [x radius=1.75, y radius=3];
% Text
\draw (-2.5,2) node (a) {-4};
\draw (-2.5,1) node (b) {-1,5};
\draw (-2.5,0) node (c) {0};
\draw (-2.5,-1) node (d) {3};
\draw (-2.5,-2) node (e) {7,25};
\draw (2.5,0) node (f) {3};
% Arrow
\draw[myArrow] (a) -- ([yshift=5pt]f.west);
\draw[myArrow] (b) -- ([yshift=2.4pt]f.west);
\draw[myArrow] (c) -- (f.west);
\draw[myArrow] (d) -- ([yshift=-2.5pt]f.west);
\draw[myArrow] (e) -- ([yshift=-5pt]f.west);
\end{tikzpicture}
\begin{tikzpicture}[
scale=\linewidth/10cm,
myArrow/.style={thick,->}]
% Help Lines
\draw[step=1,help lines,black!20] (-4.95,-2.95) grid (4.95,3.95);
% Ellipse
\draw[thick] (-2.5,0) ellipse [x radius=1.75, y radius=3];
\draw[thick] (2.5,0) ellipse [x radius=1.75, y radius=3];
% Text
\draw (-2.5,2) node (a) {-4};
\draw (-2.5,1) node (b) {-1,5};
\draw (-2.5,0) node (c) {0};
\draw (-2.5,-1) node (d) {3};
\draw (-2.5,-2) node (e) {7,25};
\draw (2.5,0) node (f) {3};
% Arrow
\draw[myArrow] (a) to[out=0,in=125] (f);
\draw[myArrow] (b) to[out=0,in=150] (f);
\draw[myArrow] (c) -- (f);
\draw[myArrow] (d) to[out=0,in=210] (f);
\draw[myArrow] (e) to[out=0,in=245] (f);
\end{tikzpicture}
\end{document}
答案2
这很容易,只需进行简单的计算。要执行此操作,我们需要库calc
,我们还将利用锚点系统来确定箭头的终点。
您的箭头是有序的,并且都指向同一个节点,因此我们可以\foreach
先用 a 来简化这一点,然后用它来计算终点坐标。如果您不理解某些内容,请随时发表评论。
输出
代码
\documentclass[margin=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}%[scale=\linewidth/10cm]
% Help Lines
\draw[step=1,help lines,black!20] (-4.95,-2.95) grid (4.95,3.95);
% Ellipse
\draw[thick] (-2.5,0) ellipse [x radius=1.75, y radius=3];
\draw[thick] (2.5,0) ellipse [x radius=1.75, y radius=3];
% Text
\node (a) at (-2.5,2) {-4};
\node (b) at (-2.5,1) {-1,5};
\node (c) at (-2.5,0) {0};
\node (d) at (-2.5,-1) {3};
\node (e) at (-2.5,-2) {7,25};
\node (f) at (2.5,0) {3};
\foreach \lett [
count=\x starting from 0,
evaluate=\x as \xx using ((\x*25)/100),
] in {a,b,c,d,e}{
\draw[thick,->] (\lett) -- ($(f.north west)!\xx!(f.south west)$);
}
\end{tikzpicture}
\end{document}