(a4) edge [line width=7pt] (a10)
我想问一下如何才能将这张图片中的分隔线向上移动:
\documentclass[border=1mm,tikz]{standalone}
\usetikzlibrary{arrows,automata,shapes.multipart,calc,decorations.text}
\begin{document}
\begin{tikzpicture}[-,>=stealth',shorten >=1pt,auto,node distance=4cm,semithick,
every text node part/.style={align=center},
%,inner sep=0pt
%,scale=0.5
]
% \tikzstyle{every state}=[fill=blue!25,text=black,draw=none]
\node[](a1) {};
\node[state,minimum size=1cm](a2) [right of=a1] {\Large$3$};
\node[](a3) [right of=a2] {};
\node[](a4) [above of=a2] {};
\node[](a5) [above of=a4] {};
\node[](a10) [above of=a5] {};
\node[state,minimum size=1cm](a6) [left of=a5] {\Large$2$};
\node[state,minimum size=1cm](a7) [above of=a6] {\Large$1$};
%
\node[state,minimum size=1cm](a8) [right of=a5] {\Large$4$};
\node[state,minimum size=1cm](a9) [above of=a8] {\Large$5$};
\begin{scope}[every node/.style={scale=1.5}]
\path (a7) edge [sloped, anchor=center,above] node {31.6 m} (a2)
(a6) edge [sloped, anchor=center,above] node {22.36 m} (a2)
(a8) edge [sloped, anchor=center,above] node {22.36 m} (a2)
(a9) edge [sloped, anchor=center,above] node {31.6 m} (a2)
(a6) edge [sloped, anchor=center,above] node {10 m} (a7)
(a8) edge [sloped, anchor=center,above] node {10 m} (a9)
(a4) edge [line width=7pt] (a10)
;
\end{scope}
\end{tikzpicture}
\end{document}
不改变节点的相对位置。该线(a4) edge [line width=7pt] (a10)
表示标记为 1、2 和 4、5 的节点对之间的无线信号屏障。
我想设置节点 a4 和 a10 的 yshift,而不改变其余节点的位置。
问候
答案1
仅从看你的照片我怀疑你想要类似的东西(a6.south-|a2) edge [line width=7pt] (a7.north-|a2)
。
\documentclass[border=1mm,tikz]{standalone}
\usetikzlibrary{arrows,automata}
\begin{document}
\begin{tikzpicture}[-,>=stealth',shorten >=1pt,auto,node distance=4cm,semithick,
every text node part/.style={align=center},
]
\node[](a1) {};
\node[state,minimum size=1cm](a2) [right of=a1] {\Large$3$};
\node[](a3) [right of=a2] {};
\node[](a4) [above of=a2] {};
\node[](a5) [above of=a4] {};
\node[](a10) [above of=a5] {};
\node[state,minimum size=1cm](a6) [left of=a5] {\Large$2$};
\node[state,minimum size=1cm](a7) [above of=a6] {\Large$1$};
%
\node[state,minimum size=1cm](a8) [right of=a5] {\Large$4$};
\node[state,minimum size=1cm](a9) [above of=a8] {\Large$5$};
\begin{scope}[every node/.style={scale=1.5}]
\path (a7) edge [sloped, anchor=center,above] node {31.6 m} (a2)
(a6) edge [sloped, anchor=center,above] node {22.36 m} (a2)
(a8) edge [sloped, anchor=center,above] node {22.36 m} (a2)
(a9) edge [sloped, anchor=center,above] node {31.6 m} (a2)
(a6) edge [sloped, anchor=center,above] node {10 m} (a7)
(a8) edge [sloped, anchor=center,above] node {10 m} (a9)
(a6.south-|a2) edge [line width=7pt] (a7.north-|a2)
;
\end{scope}
\end{tikzpicture}
\end{document}
当然,你可以进一步调整,例如([yshift=-5mm]a6.south-|a2) edge [line width=7pt] (a7.north-|a2)
收益率
请注意,您定义的节点并非都是必需的。我建议使用positioning
和根据节点的内容命名节点,这将引导我们:
\documentclass[border=1mm,tikz]{standalone}
\usetikzlibrary{arrows,automata,positioning}
\begin{document}
\begin{tikzpicture}[-,>=stealth',shorten >=1pt,auto,
node distance=3.5cm and 3.5cm,semithick,
every text node part/.style={align=center},
]
\node[state,minimum size=1cm](a3){\Large$3$};
\node[state,minimum size=1cm](a2) [above left=7cm and 3.5cm of a3] {\Large$2$};
\node[state,minimum size=1cm](a1) [above=of a2] {\Large$1$};
%
\node[state,minimum size=1cm](a4) [above right=7cm and 3.5cm of a3] {\Large$4$};
\node[state,minimum size=1cm](a5) [above=of a4] {\Large$15$};
\begin{scope}[every node/.style={scale=1.5}]
\path (a1) edge [sloped, anchor=center,above] node {31.6 m} (a3)
(a2) edge [sloped, anchor=center,above] node {22.36 m} (a3)
(a4) edge [sloped, anchor=center,above] node {22.36 m} (a3)
(a5) edge [sloped, anchor=center,above] node {31.6 m} (a3)
(a2) edge [sloped, anchor=center,above] node {10 m} (a1)
(a4) edge [sloped, anchor=center,above] node {10 m} (a5)
([yshift=-5mm]a2.south-|a3) edge [line width=7pt] (a1.north-|a3)
;
\end{scope}
\end{tikzpicture}
\end{document}