如何在 Tikz 中填充圆圈而不填充线条

如何在 Tikz 中填充圆圈而不填充线条

我想用一个角度填充一条线末端的圆。当我尝试通过简单地将节点设置为“填充”来实现这一点时,整条线都被填充了。我想知道如何只填充圆圈。这是我现在所拥有的:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\pagestyle{empty}
\begin{document}

\begin{tikzpicture}
    \draw[black, thick] (0,0) node[above,red]{Min} -- (8,0) node[above,red]{Max};
    \draw[red, fill=red] (0,0) circle(2pt);
    \draw[red, fill=red] (8,0) circle(2pt);

    \draw[red, thick] (0.02,0) |- (8,-0.6) circle(2pt)[fill] node[right]{some};
    \draw[red, thick] (0,0) |- (0,-0.9) circle(2pt) node[right]{none};
    \draw[red, thick] (8,0) |- (8,-0.3) circle(2pt) node[right]{all};
\end{tikzpicture}

\end{document}

它看起来像这样:

完全不对!

红色三角形效应是无意的。

答案1

node使用s 制作圆圈和点的替代方法。

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\pagestyle{empty}
\begin{document}

\begin{tikzpicture}[
    circ/.style={draw,circle,inner sep=0pt,minimum size=4pt},
    dot/.style={circ,fill}
    ]
    \draw[black, thick] (0,0) node[above,red]{Min} -- (8,0) node[above,red]{Max};
    \draw[red] (0,0) node[dot]{};
    \draw[red] (8,0) node[dot]{};

    \draw[red, thick] (0.02,0) |- (8,-0.6) node[dot]{} node[right]{some};
    \draw[red, thick] (0,0) |- (0,-0.9) node[circ]{} node[right]{none};
    \draw[red, thick] (8,0) |- (8,-0.3) node[circ]{} node[right]{all};
\end{tikzpicture}

\end{document}

答案2

您可以在第二行写填充命令。

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\pagestyle{empty}
\begin{document}

\begin{tikzpicture}
    \draw[black, thick] (0,0) node[above,red]{Min} -- (8,0) node[above,red]{Max};
    \draw[red, fill=red] (0,0) circle(2pt);
    \draw[red, fill=red] (8,0) circle(2pt);

    \draw[red,thick] (0.02,0) |- (8,-0.6);
    \fill[red] (8,-0.6) circle(2pt) node[right]{some};
    \draw[red, thick] (0,0) |- (0,-0.9) circle(2pt) node[right]{none};
    \draw[red, thick] (8,0) |- (8,-0.3) circle(2pt) node[right]{all};
\end{tikzpicture}

\end{document}

在此处输入图片描述

答案3

路径(0.02,0) |- (8,-0.6)本质上由两条路径组成;一条垂直,另一条水平。如果你把它分成两条开放路径,那么唯一剩下的封闭路径将是圆形,它将被正确填充。不过,还有其他(可能更好)的选项来放置这些节点。

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\pagestyle{empty}
\begin{document}

\begin{tikzpicture}
    \draw[thick] (0,0) node[above,red]{Min} -- (8,0) node[above,red]{Max};
    \draw[red,fill] (0,0) circle(2pt);
    \draw[red,fill] (8,0) circle(2pt);

    \draw[red,thick] (.02,0)--(.02,-.6) (.02,-.6)--(8,-.6) circle(2pt)[fill] node[right]{some};
    \draw[red,thick] (0,0) |- (0,-0.9) circle(2pt) node[right]{none};
    \draw[red,thick] (8,0) |- (8,-0.3) circle(2pt) node[right]{all};
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容