如何在 TikZ 中绘制分区圆?

如何在 TikZ 中绘制分区圆?

我想要画这样的东西:

图表

除了那个圆圈以外,我什么都知道。这是我的代码:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,shapes.geometric,arrows,fit,calc,positioning,automata,}
\usepackage{amsmath}

\begin{document}

\begin{tikzpicture}[shorten >=1pt,auto,node distance=3 cm, scale = 1.0, transform shape]
\tikzstyle{int}=[draw, minimum size=4em]
\tikzset{every edge/.append style={font=\Large}}
\tikzset{every node/.append style={font=\Large}}

  \node[state,minimum size=3 cm]    (A)                                 {};
  \node[state,minimum size=3 cm]        (B) [right of=A,node distance=6 cm]                 {};

  \node[int]           (C) [above of=A]                     {  };
  \node[int]           (D) [below of=A]                     {  };
  \node[int]           (E) [above of=B]                     {  };
  \node[int]           (F) [below of=B]                     {  };


  \path[->] (A) edge [] node []  {} (C);
  \path[->] (C) edge [] node []  {} (E);
  \path[->] (E) edge [] node []  {} (B);
  \path[->] (B) edge [] node []  {} (F);
  \path[->] (F) edge [] node []  {} (D);
  \path[->] (D) edge [] node []  {} (A);

\end{tikzpicture}


\end{document}

输出为:

电流输出

答案1

以下是使用\foreach及其语法的evaluate=<variable> as <macro> using <formula>一种可能性count=<macro> from <value>

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,shapes.geometric,arrows,fit,calc,positioning,automata,}
\usepackage{amsmath}

\definecolor{myblue}{RGB}{153,205,255}

\begin{document}

\begin{tikzpicture}[shorten >=1pt,auto,node distance=3 cm, scale = 1.0, transform shape,>=latex]
\tikzset{int/.style={draw, minimum size=4em,fill=myblue}}
\tikzset{every edge/.append style={font=\Large}}
\tikzset{every node/.append style={font=\Large}}

\node[state,minimum size=3 cm,fill=myblue]    (A) {};
\node[state,minimum size=3 cm,fill=myblue]    (B) [right of=A,node distance=6 cm] {};

  \node[int]           (C) [above of=A]                     {  };
  \node[int]           (D) [below of=A]                     {  };
  \node[int]           (E) [above of=B]                     {  };
  \node[int]           (F) [below of=B]                     {  };

  \path[->] (A) edge [] node []  {} (C);
  \path[->] (C) edge [] node []  {} (E);
  \path[->] (E) edge [] node []  {} (B);
  \path[->] (B) edge [] node []  {} (F);
  \path[->] (F) edge [] node []  {} (D);
  \path[->] (D) edge [] node []  {} (A);

\draw[<-] (A.180) -- +(-0.5,0);
\draw[->] (B.0) -- +(0.5,0);

\foreach \angle [evaluate=\angle as \langle using 180+\angle] in {0,45,90,135}
{
  \draw (A.\angle) -- (A.\langle);
  \draw (B.\angle) -- (B.\langle);
}
\foreach \angle [evaluate=\angle as \labangle using \angle+67.5,count=\anglei from 0] in {0,-45,...,-315}
  \node at ( $ (A) + (\labangle:1cm) $ ) {\anglei};
\end{tikzpicture}

\end{document}

在此处输入图片描述

为了获取圆上的标签,可以始终使用\foreach两个显式变量的循环:第一个变量控制标签的角度,另一个变量控制标签本身;当然,如果角度和标签之间存在某种关系,则可以使用语法evaluate=<variable> as <macro> using <formula>来简化事情;以下示例说明了这一点:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,automata}

\definecolor{myblue}{RGB}{153,205,255}

\begin{document}

\begin{tikzpicture}

\node[state,minimum size=3 cm,fill=myblue]  (A) {};
\node[state,minimum size=3 cm,fill=myblue]  (B) [right of=A,node distance= 6cm] {};

\foreach \angle [evaluate=\angle as \langle using 180+\angle] in {0,45,90,135}
{
  \draw (A.\angle) -- (A.\langle);
  \draw (B.\angle) -- (B.\langle);
}

\foreach \angle/\label in {67.5/-5,22.5/4,-22.5/6,-67.5/-1,-112.5/7,-157.5/-8,-202.5/-2,-247.5/0}
  \node at ( $ (A) + (\angle:1cm) $ ) {\label};
\foreach \angle [evaluate=\angle as \langle using (292.5+\angle)/30] in {67.5,22.5,...,-247.5}
  \node at ( $ (B) + (\angle:1cm) $ ) {\langle};
\end{tikzpicture}

\end{document}

在此处输入图片描述

答案2

我的评论中提到的形状可以从以下简单的代码中获得:

\documentclass[a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{shapes,positioning}
\begin{document}
\begin{tikzpicture}[node distance=1cm,blue]
\centering

\node[circle split,draw,] (s1) {Circle \nodepart{lower} split}; 
 \node[forbidden sign,text width=4em, text centered,below=of s1,draw] (s2) {Forbidden sign}; 

\node[cross out,below=of s2,draw] (s3)  {Cross out};

\end{tikzpicture}

\end{document}

结果如下: 形状库中的一些形状可能对这个问题有用

相关内容