绘制圆周上有对象的圆形图

绘制圆周上有对象的圆形图

我想绘制一个圆周上有物体的圆形图,类似于 Zarko 提供的这个 MWE(运行此代码时我的电脑出现错误,但对于 Zarko 来说它运行正常):

    \documentclass[border=3.141592mm]{standalone}

\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                positioning}

    \begin{document}
        \begin{tikzpicture}[
    node distance = 22mm and 11mm,
         C/.style = {circle, draw, minimum size=#1},
       C/.default = 24mm
    every label/.append style = {inner sep=1pt}
                            ]
    \node (a) [C]   {};
        \foreach \i in {30, 150, 270}
            \draw (a.center)  ++ (\i:9mm) -- ++ (\i:6mm); 
        \node[font=\Large, label= above:A, label=below:1]   at (a.90) {$\times$};
        \node[C=2mm, label=210:B, label=30:2]   at (a.210) {};
        \node[C=2mm, label=330:C,label=150:3]   at (a.330) {};
    \node (b) [C, below  left=of a]  {};
    \node (c) [C, below right=of a]  {};
    %
    \draw[very thick, -Straight Barb]   ([yshift=-4mm] a.south) -- ++ (0,-7mm);
        \end{tikzpicture}
    \end{document}

我需要一个圆,将其均匀地切成 3 部分,分别标记为 A、B 和 C,并在切割圆周内有物体(圆形和“x”)。

编辑:首先,感谢 gernot 的回答。现在,我要在页面上添加以下信息:

\begin{align*}
\textbf{Time 0}\\
(i)  \quad  1&=i \text{ in } A\\
(ii) \quad  2&=s \text{ in } B\\
(iii)\quad  3&=s \text{ in } C\\ 
\end{align*}

\text{Let  } $[(i,A), (s,B), (s,C)]= X$.

所以这就是我想要的页面分割方式:|x|x|image| 换句话说,我想将页面分成 3 部分(没有线条),并在标记为“x”的位置显示信息。我不知道如何对齐所有 3 个项目。

在此处输入图片描述

答案1

下面的代码定义了一个命令

 \board[optional scale factor]{list of triples angle/number/mark}

绘制圆形图。可选参数是比例因子,默认为 1.0。强制参数是一个逗号分隔的三元组列表,如90/1/\cross(12 点钟位置的节点编号为 1,并标有十字)或210/2/(8 点钟位置的节点编号为 2,无标记)。

在此处输入图片描述

\documentclass{article}
\usepackage{tikz}
% \board[optional scale factor, default 1.0]{list of triples angle/number/mark}
\newcommand\board[2][1.0]{%
  \begin{tikzpicture}[baseline={(0,0)},scale=#1]
    \draw (0,0) circle (1);
    % radial lines at angles 30°, 150° and 270°
    \foreach \a in {30, 150, 270}
      \draw (\a:0.9) -- (\a:1.1);
    % label A/B/C outside of circle at angles 90°, 210° and 330°
    \foreach \a/\l in {90/A,210/B,330/C}
      \node at (\a:1.4) {\scriptsize$\l$};
    % draw game positions
    % \a ... angle, \n ... number 1/2/3, \m ... mark  
    \foreach \a/\n/\m in {#2} {
      % node
      \node[circle,draw,minimum size=1em,inner sep = 0,fill=white] at (\a:1) {\m};
      % number inside of circle
      \node at (\a:0.6) {\scriptsize$\n$};
  }
  \end{tikzpicture}%
}
\newcommand\cross{$\times$}
\begin{document}
\begin{center}
  \board[0.8]{90/1/\cross,210/2/,330/3/}\\
  \begin{tabular}[t]{@{}c@{}}
    \board[0.8]{90/2/,190/1/\cross,230/3/}\\
    move
  \end{tabular}
  \begin{tabular}[t]{@{}c@{}}
    \board[0.8]{90/2/,190/1/,230/3/\cross}\\
    status
  \end{tabular}
\end{center}
\end{document}

要按图片所示排列文本和图表,您可以使用 LaTeX 提供的所有功能。这些\board{...}命令的作用类似于居中对齐的(大)字母。对于其他图形元素,您可以使用我对“如何在方程和矩阵中添加箭头?”的回答

在此处输入图片描述

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows} % needed for arrow tip stealth'
\newcommand\tikznode[3][]{%
  \tikz[remember picture,baseline=(#2.base)]
    \node[minimum size=0pt,inner sep=0pt,#1](#2){#3};%
}
% \board[optional scale factor, default 1.0]{list of triples angle/number/mark}
\newcommand\board[2][1.0]{%
  \begin{tikzpicture}[baseline={(0,0)},scale=#1]
    \draw (0,0) circle (1);
    % radial lines at angles 30°, 150° and 270°
    \foreach \a in {30, 150, 270}
      \draw (\a:0.9) -- (\a:1.1);
    % label A/B/C outside of circle at angles 90°, 210° and 330°
    \foreach \a/\l in {90/A,210/B,330/C}
      \node at (\a:1.4) {\scriptsize$\l$};
    % draw game positions
    % \a ... angle, \n ... number 1/2/3, \m ... mark  
    \foreach \a/\n/\m in {#2} {
      % node
      \node[circle,draw,minimum size=1em,inner sep = 0,fill=white] at (\a:1) {\m};
      % number inside of circle
      \node at (\a:0.6) {\scriptsize$\n$};
  }
  \end{tikzpicture}%
}
\newcommand\cross{$\times$}
\begin{document}

\paragraph{Time 0}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
  $1=i$ in $A$\\
  $2=s$ in $B$\\
  $3=s$ in $C$
\end{tabular}
$\longrightarrow$
\tikznode{X}{$[(i,A),(s,B),(s,C)]=X$}
\board[0.9]{90/1/\cross,210/2/,330/3/}

\paragraph{Time 1}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
  $1=r$ in $B$\\
  $2=s$ in $A$\\
  $3=i$ in $B$
\end{tabular}
$\longrightarrow$
\tikznode{Y}{$[(r,B),(s,A),(i,B)]=Y$}
\begin{tabular}[t]{@{}c@{}}
  \board[0.9]{90/2/,190/1/\cross,230/3/}\\
  move
\end{tabular}
\begin{tabular}[t]{@{}c@{}}
  \board[0.9]{90/2/,190/1/,230/3/\cross}\\
  status
\end{tabular}

\begin{tikzpicture}[remember picture,overlay,>=stealth',shorten <=2pt,shorten >=2pt]
  \draw[->] (X) edge[bend left] node[right]{$P_{xy}=p/8$} (Y);
\end{tikzpicture}
\end{document}

相关内容