如何填充坐标圆?

如何填充坐标圆?

正如标题所写,我在定义箭头之间绘制的圆圈的填充颜色时遇到了问题。

提前谢谢您:) 在此处输入图片描述 代码如下:(错误可能出现在上部四分之一处)

PS:图片中有未填充的圆圈,看不清楚

\documentclass[border=10pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc,arrows, shapes}
% \tikzset{>=latex} //alternative Pfeilvisualisierung
\begin{document}
\begin{figure}
        \centering
\begin{tikzpicture} [scale=0.7]

    %   [circle/.style ={circle, fill=black}]
    %   \setcolor {black};

    \let\radius\undefined
    \newlength{\radius}
    \setlength{\radius}{0.3mm}

    %%%%%%%%%%%%%%
    \tikzstyle {every coordinate}=[draw, shape = circle,fill = black, scale= 2]
    %%%%%%%%% Mistake probably here: every coordinate(?) or circle.. dont know


    %Weg
    \coordinate (p1) at (0,0);
    \coordinate (p2) at (0,2);
    \coordinate (p3) at (0,4);
    \coordinate (p4) at (0,6);
    \coordinate (p5) at (0,8);

    \coordinate (p6) at (1.5,6.5);
    \coordinate (p7) at (2.25,7.25);
    \coordinate (p8) at (3,6.5);
    \coordinate (p9) at (2.25,5.75);

    \coordinate (p10) at (2.25,4.25);
    \coordinate (p11) at (2.25, 2.75);
    \coordinate (p12) at (2.25,1.75);

    \coordinate (p13) at (-1.5,6.5);
    \coordinate (p14) at (-2.8,7.1);
    \coordinate (p15) at (-2.6,5.7);

    \coordinate (p16) at (-3.4,8.2);
    \coordinate (p17) at (-3.4,4.5);
    \coordinate (p18) at (-3.9,3.7);


    \draw (p1) circle (\radius) node [below=1.5mm] {$u$};
    \draw (p2) circle (\radius) node [] {};
    \draw (p3) circle (\radius) node [] {};
    \draw (p4) circle (\radius) node [xshift=3.5mm, below=0.5 mm] {$x_{j}$};
    \draw (p5) circle (\radius) node [above=1mm] {$x_{n}$};
    \draw (p6) circle (\radius) node [] {};
    \draw (p7) circle (\radius) node [] {};
    \draw (p8) circle (\radius) node [] {};
    \draw (p9) circle (\radius) node [xshift=3mm, below=0.2mm] {$x_{j_1}$};
    \draw (p10) circle (\radius) node [] {};
    \draw (p11) circle (\radius) node [xshift=3.5mm, below=2.7mm] {$x_{j_3}$};
    \draw (p12) circle (\radius) node [xshift=3.5mm, above=2.7mm] {$x_{j_2}$};
    \draw (p13) circle (\radius) node [] {};
    \draw (p14) circle (\radius) node [] {};
    \draw (p15) circle (\radius) node [] {};
    \draw (p16) circle (\radius) node [] {};
    \draw (p17) circle (\radius) node [] {};
    \draw (p18) circle (\radius) node [] {};


    %Pfeile
    %Mittig
    \draw [->, line width=1.7,shorten >=3pt, shorten <=3pt] (p1) -- (p2);
    \draw [->, line width=1.7,shorten >=3pt, shorten <=3pt] (p2) -- (p3);
    \draw [->, line width=1.7,shorten >=3pt, shorten <=3pt] (p3) -- (p4);
    \draw [->, line width=0.8,shorten >=3pt, shorten <=3pt] (p4) -- (p5);

    \draw [->, line width=1.7,shorten >=3pt, shorten <=3pt] (p4) -- (p6);

    %Kreis oben rechts
    \draw [->,line width=1.7, shorten >=3pt, shorten <=3pt] (p6) to [out=90,in=190] (p7);
    \draw [->,line width=1.7, shorten >=3pt, shorten <=3pt] (p7) to [out=0,in=100] (p8);
    \draw [->,line width=1.7, shorten >=3pt, shorten <=3pt] (p8) to [out=270,in=10] (p9);
    \draw [->,line width=0.8, shorten >=3pt, shorten <=3pt] (p9) to [out=180,in=280] (p6);  

    %Kreis mitte rechts
    \draw [->, line width=1.7, shorten <= 3pt, shorten >= 3pt] (p9) to (p10);
    \draw [->,line width=1.7, shorten >=3pt, shorten <=3pt] (p10) to [out=210,in=150] (p11);
    \draw [->,line width=0.8, shorten >=2.8pt, shorten <=3pt] (p11) to [out=20,in=330] (p10);

    %Kreis unten rechts
    \draw [->, line width=0.8, shorten <=3pt, shorten >=3pt] (p11) to (p12);
    \draw[thick,->, shorten <=4pt] (p12) arc (90:435:4.2mm);

    %Kreis mitte links
    \draw [->, bend angle=-45, bend left, line width=0.8, shorten >=3pt, shorten <=3pt] (p13) to (p14);
    \draw [->, bend angle=-45, bend left, line width=0.8, shorten >=3pt, shorten <=3pt] (p14) to (p15);
    \draw [->, bend angle=-45, bend left, line width=0.8, shorten >=3pt, shorten <=3pt] (p15) to (p13);


    %Pfeile links
    \draw [->, line width=0.8,shorten >=3pt, shorten <=3pt] (p4) -- (p13);
    \draw [->, line width=0.8,shorten >=3pt, shorten <=3pt] (p15) -- (p17);
    \draw [->, line width=0.8,shorten >=3pt, shorten <=3pt] (p14) -- (p16);

    %Kreis oben links
    \draw[thick,->, shorten <=4pt] (p16) arc (-90:250:0.4);

    %Kreis unten links
    \draw [->, line width=0.8, shorten >=2pt, shorten <=3pt] (p17) to [out=180,in=120] (p18);
    \draw [->,line width=0.8, shorten >=2pt, shorten <=2.8pt] (p18) to [out=0,in=290] (p17);


    %IstGleich Striche
    \draw (-0.15,6.95) -- (0.15,7.05);
    \draw (-0.15,6.85) -- (0.15,6.95);

    \draw (1.54,5.85) -- (1.81,6.05);
    \draw (1.67,5.8) -- (1.93,6);

    \draw (2.55,3.5) -- (2.85,3.6);
    \draw (2.55,3.6) -- (2.85,3.7);

    \draw (1.7,1.15) -- (2,1.25);
    \draw (1.7,1.25) -- (2,1.35);

\end{tikzpicture}

\caption{Docking a cactus. The edges to be deleted are indicated. The resulting stem is set in bold.} 
\label{Fig.: 6.3.4}

\end{figure}
\end{document}

答案1

一个如何更简洁地编写代码的示例。我做了以下操作:

  • 所有坐标均由节点替换
  • 为这些节点定义样式dot,提供具有规定半径的黑色填充圆圈(这也可以解决您的问题)
  • 节点相对放置
  • 对于我使用的线条edges

\documentclass[tikz, border=10pt]{standalone}
\usetikzlibrary{arrows.meta, bending, positioning}

\begin{document}
    \begin{tikzpicture}[scale=0.7,
node distance = 20mm and 15mm,
dot/.style = {circle, fill, minimum size=2*\radius, inner sep=0pt,
              node contents={},
             },
 LT/.style = {-{Straight Barb[bend]}, line width=1.7, shorten >=2pt, shorten <=2pt},
 Lt/.style = {-{Straight Barb[bend]}, line width=0.8, shorten >=2pt, shorten <=2pt},
bend angle =45
                    ]
    \let\radius\undefined
    \newlength{\radius}
    \setlength{\radius}{1mm}
    %Weg
\node (p1) [dot,label=below:$u$];
\node (p2) [dot,above=of p1];
\node (p3) [dot,above=of p2];
\node (p4) [dot,above=of p3,label={[yshift=3pt]below right:$x_j$}];
\node (p5) [dot,above=of p4,label=$x_n$];
% recht
    \begin{scope}[node distance = 6mm and 6mm]
\node (p6) [dot, above right=1mm and 15mm of p4];
\node (p7) [dot, above right=of p6];
\node (p8) [dot, below right=of p7];
\node (p9) [dot, below  left=of p8,label=below right:$x_{j_1}$];
    \end{scope}
\node (p10) [dot,below=of p9];
\node (p11) [dot,below=10mm of p10, label=right:$x_{j2}$];
\node (p12) [dot,below=10mm of p11, label=right:$x_{j3}$];
% links
    \begin{scope}[node distance = 5mm and 10mm]
\node (p13) [dot, above left=1mm and 15mm of p4];
\node (p14) [dot, above left=of p13];
\node (p15) [dot, below left=of p13];
    \end{scope}
    \begin{scope}[node distance = 10mm and 6mm]
\node (p16) [dot, above left=of p14];
\node (p17) [dot, below left=of p15];
\node (p18) [dot, below left=of p17];
    \end{scope}
% paths
\path[LT]   (p1) edge (p2)
            (p2) edge (p3)
            (p3) edge (p4)
%
            (p4) edge (p6)
            (p6) edge [bend left] (p7)
            (p7) edge [bend left] (p8)
            (p8) edge [bend left] (p9)
            (p9) edge (p10)
            (p10) edge [bend right] (p11)
            ;
\path[Lt]   (p4) edge node[rotate=-60] {$\|$} (p5)
% recht
            (p9)  edge [bend  left] node[rotate=-60] {$\|$} (p6)
            (p11) edge [bend right] node[rotate=-60] {$\|$} (p10)
            (p11) edge (p12)
            (p12) edge [out=225, in=315, min distance=12mm] node[rotate=30] {$\|$} (p12)
% links
            (p4)  edge (p13)
            (p13) edge [bend right] (p14)
            (p13) edge [bend  left] (p15)
            (p14) edge [bend right] (p15)
%
            (p14) edge (p16)
            (p16) edge [out=45, in=135, min distance=12mm] (p16)
%
            (p15) edge (p17)
            (p17) edge [bend right] (p18)
            (p18) edge [bend right] (p17)
            ;
    \end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

您应该在 后添加[fill]或。[fill=black]\draw

\documentclass[border=10pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc,arrows, shapes}
% \tikzset{>=latex} //alternative Pfeilvisualisierung
\begin{document}
    \begin{figure}
        \centering
        \begin{tikzpicture} [scale=0.7]

        %   [circle/.style ={circle, fill=black}]
        %   \setcolor {black};

        \let\radius\undefined
        \newlength{\radius}
        \setlength{\radius}{0.3mm}




        %Weg
        \coordinate (p1) at (0,0);
        \coordinate (p2) at (0,2);
        \coordinate (p3) at (0,4);
        \coordinate (p4) at (0,6);
        \coordinate (p5) at (0,8);

        \coordinate (p6) at (1.5,6.5);
        \coordinate (p7) at (2.25,7.25);
        \coordinate (p8) at (3,6.5);
        \coordinate (p9) at (2.25,5.75);

        \coordinate (p10) at (2.25,4.25);
        \coordinate (p11) at (2.25, 2.75);
        \coordinate (p12) at (2.25,1.75);

        \coordinate (p13) at (-1.5,6.5);
        \coordinate (p14) at (-2.8,7.1);
        \coordinate (p15) at (-2.6,5.7);

        \coordinate (p16) at (-3.4,8.2);
        \coordinate (p17) at (-3.4,4.5);
        \coordinate (p18) at (-3.9,3.7);


        \draw[fill=black] (p1) circle (\radius) node [below=1.5mm] {$u$};
        \draw[fill=black] (p2) circle (\radius) node [] {};
        \draw[fill=black] (p3) circle (\radius) node [] {};
        \draw[fill=black] (p4) circle (\radius) node [xshift=3.5mm, below=0.5 mm] {$x_{j}$};
        \draw[fill=black] (p5) circle (\radius) node [above=1mm] {$x_{n}$};
        \draw[fill=black] (p6) circle (\radius) node [] {};
        \draw[fill=black] (p7) circle (\radius) node [] {};
        \draw[fill=black] (p8) circle (\radius) node [] {};
        \draw[fill=black] (p9) circle (\radius) node [xshift=3mm, below=0.2mm] {$x_{j_1}$};
        \draw[fill=black] (p10) circle (\radius) node [] {};
        \draw[fill=black] (p11) circle (\radius) node [xshift=3.5mm, below=2.7mm] {$x_{j_3}$};
        \draw[fill=black] (p12) circle (\radius) node [xshift=3.5mm, above=2.7mm] {$x_{j_2}$};
        \draw[fill=black] (p13) circle (\radius) node [] {};
        \draw[fill=black] (p14) circle (\radius) node [] {};
        \draw[fill=black] (p15) circle (\radius) node [] {};
        \draw[fill=black] (p16) circle (\radius) node [] {};
        \draw[fill=black] (p17) circle (\radius) node [] {};
        \draw[fill=black] (p18) circle (\radius) node [] {};


        %Pfeile
        %Mittig
        \draw [->, line width=1.7,shorten >=3pt, shorten <=3pt] (p1) -- (p2);
        \draw [->, line width=1.7,shorten >=3pt, shorten <=3pt] (p2) -- (p3);
        \draw [->, line width=1.7,shorten >=3pt, shorten <=3pt] (p3) -- (p4);
        \draw [->, line width=0.8,shorten >=3pt, shorten <=3pt] (p4) -- (p5);

        \draw [->, line width=1.7,shorten >=3pt, shorten <=3pt] (p4) -- (p6);

        %Kreis oben rechts
        \draw [->,line width=1.7, shorten >=3pt, shorten <=3pt] (p6) to [out=90,in=190] (p7);
        \draw [->,line width=1.7, shorten >=3pt, shorten <=3pt] (p7) to [out=0,in=100] (p8);
        \draw [->,line width=1.7, shorten >=3pt, shorten <=3pt] (p8) to [out=270,in=10] (p9);
        \draw [->,line width=0.8, shorten >=3pt, shorten <=3pt] (p9) to [out=180,in=280] (p6);  

        %Kreis mitte rechts
        \draw [->, line width=1.7, shorten <= 3pt, shorten >= 3pt] (p9) to (p10);
        \draw [->,line width=1.7, shorten >=3pt, shorten <=3pt] (p10) to [out=210,in=150] (p11);
        \draw [->,line width=0.8, shorten >=2.8pt, shorten <=3pt] (p11) to [out=20,in=330] (p10);

        %Kreis unten rechts
        \draw [->, line width=0.8, shorten <=3pt, shorten >=3pt] (p11) to (p12);
        \draw[thick,->, shorten <=4pt] (p12) arc (90:435:4.2mm);

        %Kreis mitte links
        \draw [->, bend angle=-45, bend left, line width=0.8, shorten >=3pt, shorten <=3pt] (p13) to (p14);
        \draw [->, bend angle=-45, bend left, line width=0.8, shorten >=3pt, shorten <=3pt] (p14) to (p15);
        \draw [->, bend angle=-45, bend left, line width=0.8, shorten >=3pt, shorten <=3pt] (p15) to (p13);


        %Pfeile links
        \draw [->, line width=0.8,shorten >=3pt, shorten <=3pt] (p4) -- (p13);
        \draw [->, line width=0.8,shorten >=3pt, shorten <=3pt] (p15) -- (p17);
        \draw [->, line width=0.8,shorten >=3pt, shorten <=3pt] (p14) -- (p16);

        %Kreis oben links
        \draw[thick,->, shorten <=4pt] (p16) arc (-90:250:0.4);

        %Kreis unten links
        \draw [->, line width=0.8, shorten >=2pt, shorten <=3pt] (p17) to [out=180,in=120] (p18);
        \draw [->,line width=0.8, shorten >=2pt, shorten <=2.8pt] (p18) to [out=0,in=290] (p17);


        %IstGleich Striche
        \draw (-0.15,6.95) -- (0.15,7.05);
        \draw (-0.15,6.85) -- (0.15,6.95);

        \draw (1.54,5.85) -- (1.81,6.05);
        \draw (1.67,5.8) -- (1.93,6);

        \draw (2.55,3.5) -- (2.85,3.6);
        \draw (2.55,3.6) -- (2.85,3.7);

        \draw (1.7,1.15) -- (2,1.25);
        \draw (1.7,1.25) -- (2,1.35);

        \end{tikzpicture}

        \caption{Docking a cactus. The edges to be deleted are indicated. The resulting stem is set in bold.} 
        \label{Fig.: 6.3.4}

    \end{figure}
\end{document}

相关内容