我正在尝试使用 tikz 包重现附图,但很难拆分其中带有 {X,x} 的节点。有什么建议吗?
这是我目前想到的办法,但还不够好。{X,x} 节点需要旋转和分割,如图所示(颜色不重要):
\begin{tikzpicture}
\node [circle split,
draw,
line width = .05cm,
minimum width=1cm,
append after command={%
let \p1=($(\tikzlastnode.east)-(\tikzlastnode.west)$) in
node[draw,
shape=semicircle,
rotate=180,
anchor=south,
double,
minimum width=\x1] at (\tikzlastnode.center) {}}]
{$X$
\nodepart{lower}
$x$
};
\node [ellipse,draw,line width=.05cm] at (3.75,0) {$Y(x)$};
\node [circle,draw,line width=.05cm] at (1.5,3) {$L$};
\node [circle,draw,line width=.05cm] at (4,4.5) {$H$};
\draw[->, line width=.125cm] (1.1,0) -- (2.5,0);
\draw[->, line width=.125cm] (0.9,3) to [out=180,in=90] (-.5,1);
\draw[->, line width=.125cm] (1.8,2.6) -- (3,.75);
\draw[->, line width=.125cm] (3.45,4.2) -- (2.1,3.25);
\draw[->, line width=.125cm] (4,3.9) -- (4,.85);
%\draw[help lines] (0,0) grid (8,6) ;
\end{tikzpicture}
答案1
semicircle
为什么不使用库中的旋转形状shapes.geometric
?
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,positioning}
\tikzset{
semi/.style={
semicircle,
draw,
minimum size=2em
}
}
\begin{document}
\begin{tikzpicture}[line width=0.05cm]
\node [circle,draw] (h) {$H$};
\node [circle,draw,below left=1cm and 1.5cm of h] (l) {$L$};
\node [ellipse,draw,below=3.5cm of h] (y) {$Y(x)$};
\node[semi,left=2cm of y,shape border rotate=270] (x) {$x$};
\node[semi,left=0.3cm of x,shape border rotate=90] (X) {$X$};
\begin{scope}[line width=.125cm,shorten >= 5pt, shorten <= 5pt]
\draw[->] (x) -- (y);
\draw[->] (l) to [out=180,in=90] (X);
\draw[->] (l) -- (y);
\draw[->] (h) -- (l);
\draw[->] (h) -- (y);
\end{scope}
%\draw[help lines] (0,0) grid (8,6) ;
\end{tikzpicture}
\end{document}
请注意,我使用positioning
库来放置节点,因此您不必手动指定坐标;我还使用了scope
带有shorten
选项来绘制边。