我有以下图表:
\begin{figure}
\begin{tikzpicture}
\node[shape=circle,draw=black,minimum size=1cm] (0) at (0,0) {$0$};
\node[shape=circle,draw=black,minimum size=1cm] (11) at (-1,0) {$-1$};
\node[shape=circle,draw=black,minimum size=1cm] (12) at (-2,0) {$-2$};
\node[shape=circle,draw=black,minimum size=1cm] (13) at (-3,0) {$-3$};
\node[shape=circle,draw=black,minimum size=1cm] (14) at (-4,0) {$-4$};
\node[shape=circle,draw=black,minimum size=1cm] (1) at (1,0) {$1$};
\node[shape=circle,draw=black,minimum size=1cm] (2) at (2,0) {$2$};
\node[shape=circle,draw=black,minimum size=1cm] (3) at (3,0) {$3$};
\node[shape=circle,draw=black,minimum size=1cm] (4) at (4,0) {$4$};
\draw (0) -- (1);
\draw (2) -- (1);
\draw (3) -- (2);
\draw (4) -- (3);
\draw (0) --(11);
\draw (11) -- (12);
\draw (12) -- (13);
\draw (13) --(14);
\end{tikzpicture}
\end{figure}
在这张图片中,节点之间的边缘不可见。如何使边缘可见?
其次,我希望节点在两个方向上都连续,即我希望图形在两侧都是无限的。有人能帮我如何让图形无限吗?
如果有人能解决这个问题我将非常感激。
答案1
您看不到线条的原因是您的节点太大。将 改为minimum size=1cm
,minimum size=0.5cm
您就会看到它们。
我不知道你说的“让图形无限”是什么意思,但我认为你可能想要实现的是:我使用了循环,foreach
这样你就不必一遍又一遍地复制和粘贴代码。
\documentclass[border=3.5mm]{standalone}
\usepackage{tikz}
\pgfdeclarelayer{bg}
\pgfsetlayers{bg,main}
\begin{document}
$\raisebox{2ex}{$\cdots$}$
\begin{tikzpicture}
\foreach\x in {-10,...,-5,-4,-3,-2,-1,0,1,2,3,4,5,...,10}
\draw [] (\x,0) circle (1 mm) node[fill=white,draw=black,circle,inner sep=2pt,minimum size=0.8cm] {\x};
\begin{pgfonlayer}{bg}
\draw[red ] (0,0)
\foreach \x in {-10,...,-5,-4,-3,-2,-1,0,1,2,3,4,5,...,10}
{-- (\x,0)};
\end{pgfonlayer}
\end{tikzpicture}
$\raisebox{2ex}{$\cdots$}$
\end{document}