更改箭头的锚点

更改箭头的锚点

如何改变椭圆上箭头的起始和终止位置?

\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary[arrows.meta,bending]
\usetikzlibrary{shapes.geometric,positioning}

\newcommand{\MyEllipse}[3]
   {(#1) ellipse [x radius=#2,y radius=#3]}

\begin{document}

\begin{tikzpicture}
   [arr/.style={->,shorten >= 8pt,shorten <= 8pt,thick},>=stealth]

\draw [fill=orange] \MyEllipse{0,0}{0.75}{0.5} node (e1) {$y_1$}; 

\draw [fill=orange] \MyEllipse{3,0}{0.75}{0.5} node (e2) {$y_2$}; 

\draw [fill=orange] \MyEllipse{6,0}{0.75}{0.5} node (e3) {$y_3$};

\draw[arr] (e1) to [bend left=-50] node [above=-0.75cm] {$\times(1+t_1)$} (e2);
\draw[arr] (e2) to [bend left=-50] node [above=-0.75cm] {$\times(1+t_2)$} (e3);
\draw[arr] (e1) to [bend left=-90] node [above=-0.75cm] {$\times(1+T)$}  (e3);
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案1

使用当前方法,您可以绘制\draw椭圆,然后使用\nodes 将标签放置在其中。如果您想微调箭头的起点和终点,这将产生问题,因为将使用节点的锚点,而这些锚点不一定与椭圆的边框匹配。

如果您想要更好地控制箭头,我建议您使用椭圆\node形;这样,您就可以访问节点锚点,将箭头的起点和终点放在所需的位置;这是一个我使用锚点south和一些角度锚点的小比较示例:

\documentclass[border=5pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary[arrows.meta,bending]
\usetikzlibrary{shapes.geometric,positioning}

\newcommand{\MyEllipse}[3]
   {(#1) ellipse [x radius=#2,y radius=#3]}

\begin{document}

\begin{tikzpicture}[
  arr/.style={->,thick},
  >=stealth,
  mynode/.style={
    fill=orange,
    ellipse,
    draw,
    text width=0.75cm,
    minimum height=1cm,
    align=center
  }
]

\node[mynode] (e1) {$y_1$}; 
\node[mynode,right=of e1] (e2) {$y_2$}; 
\node[mynode,right=of e2] (e3) {$y_3$}; 

\draw[arr] 
  (e1) to [bend left=-50] node [above=-0.75cm] {$\times(1+t_1)$} (e2);
\draw[arr] 
  (e2) to [bend left=-50] node [above=-0.75cm] {$\times(1+t_2)$} (e3);
\draw[arr] 
  (e1) to [bend left=-90] node [above=-0.75cm] {$\times(1+T)$}  (e3);

\begin{scope}[xshift=8cm]
\node[mynode] (e1) {$y_1$}; 
\node[mynode,right=of e1] (e2) {$y_2$}; 
\node[mynode,right=of e2] (e3) {$y_3$}; 

\draw[arr] 
  (e1.south) to [bend left=-50] node [above=-0.6cm] {$\times(1+t_1)$} (e2.south);
\draw[arr] 
  (e2.south) to [bend left=-50] node [above=-0.6cm] {$\times(1+t_2)$} (e3.south);
\draw[arr] 
  (e1.south) to [bend left=-90] node [above=-0.75cm] {$\times(1+T)$}  (e3.south);
\end{scope}

\begin{scope}[yshift=-4cm]
\node[mynode] (e1) {$y_1$}; 
\node[mynode,right=of e1] (e2) {$y_2$}; 
\node[mynode,right=of e2] (e3) {$y_3$}; 

\draw[arr] 
  (e1.340) to [bend left=-50] node [above=-0.6cm] {$\times(1+t_1)$} (e2.200);
\draw[arr] 
  (e2.340) to [bend left=-50] node [above=-0.6cm] {$\times(1+t_2)$} (e3.200);
\draw[arr] 
  (e1.220) to [bend left=-90] node [above=-0.75cm] {$\times(1+T)$}  (e3.320);
\end{scope}
\end{tikzpicture}

\end{document}

结果:

在此处输入图片描述

相关内容