创建区间图

创建区间图

我正在尝试使用以下方法创建以下图形tikz

在此处输入图片描述 有人能告诉我正确的方法吗?这是我到目前为止所做的:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\tikz\draw [o-o] (0,0) -- +(1,0) ;
\end{document}

谢谢!

答案1

像这样:

在此处输入图片描述

代码:

documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{chains}
\makeatletter
\tikzset{reset join/.code={\def\tikz@after@path{}}}
\makeatother

\begin{document}
\begin{tikzpicture}[
node distance = 3mm and 12mm,
start chain = A going right,
 dot/.style = {shape=circle, fill=black, inner sep=0mm, minimum size=1mm,
               node contents={}, join, on chain=A},
rdot/.style = {dot, fill=red, minimum size=2mm},
bdot/.style = {dot, fill=blue, minimum size=1.5mm},
                    ]
\node[dot,label=below:0];             % A-1
\node[rdot];
\node[dot,coordinate];
\node[bdot];
\node[dot,coordinate];
\node[rdot];
\node[dot,label=below:1];             % A-7
%
\node[rdot,reset join,above right=of A-7, label={[text=red]right: 1 player}];
\node[bdot,reset join,below right=of A-7, label={[text=blue]right:2 player}];
%
\coordinate[above=of A-1] (A-0);
\draw[shorten >=0.5mm, shorten <=0.5mm]
    (A-0)           edge node[fill=white] {$\frac{1}{6}$} (A-0 -| A-2)
    (A-0 -| A-2)    edge node[fill=white] {$\frac{1}{3}$} (A-0 -| A-4)
    (A-0 -| A-4)    edge node[fill=white] {$\frac{1}{3}$} (A-0 -| A-6)
    (A-0 -| A-6)     to  node[fill=white] {$\frac{1}{6}$} (A-0 -| A-7);
\end{tikzpicture}
\end{document}

相关内容