我正在尝试创建一维相图。我需要做的是将箭头放置在垂直轴上指向上方或指向下方的点上。我知道我可以使用多条端到端连接的路径来创建所需的效果。我的问题是:是否可以将箭头用作节点?沿着我的 MWE 中给出的 y 轴,我需要三个箭头:在 (0,3.25) 和 (0,0.5) 处指向上方(北),在 (0,-2.75) 处指向下方(南)。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[>=latex,font=\footnotesize]
\draw[<->,very thick,dashed,blue,samples=100,domain=-4:4] plot (\x,{-1+0*(\x)});
\node[right] at (4,-1) {$y=-1$};
\draw[<->,very thick,dashed,blue,samples=100,domain=-4:4] plot (\x,{2+0*(\x)});
\node[right] at (4,2) {$y=2$};
\draw[->,thick] (0,-4.5) -- (0,4.5) node[below right]{$y$};
\end{tikzpicture}
\end{document}
答案1
我不确定您想要哪种形状,但single arrow
库中的形状shapes.arrows
相当灵活。以下是与您的其他箭头相当接近的形状:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.arrows}
\begin{document}
\begin{tikzpicture}[>=latex,font=\footnotesize]
\draw[<->,very thick,dashed,blue,samples=100,domain=-4:4]
plot (\x,{-1+0*(\x)});
\node[right] at (4,-1) {$y=-1$};
\draw[<->,very thick,dashed,blue,samples=100,domain=-4:4]
plot (\x,{2+0*(\x)});
\node[right] at (4,2) {$y=2$};
\draw[->,thick] (0,-4.5) -- (0,4.5) node[below right]{$y$};
\begin{scope}[every node/.style={draw,fill,single arrow,
single arrow tip angle=30,
single arrow head extend=2pt,
single arrow head indent=1pt,
inner sep=0pt}]
\node[shape border rotate=90] at (0,3.25) {};
\node[shape border rotate=90] at (0,0.5) {};
\node[shape border rotate=270] at (0,-2.75) {};
\end{scope}
\end{tikzpicture}
\end{document}