如何用 TikZ 绘制规则圆角六边形?

如何用 TikZ 绘制规则圆角六边形?

我想要绘制下面的图,它是六个正圆角六边形、环、圆圈和标签。

六个规则圆角六边形、圆环和标签

答案1

使用path picture您可以创建带有内部圆圈的六角节点。

在此处输入图片描述

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\tikzset{
    myhex/.style={draw, thick, regular polygon, regular polygon sides=6, minimum size=4cm, rounded corners, path picture={\fill(path picture bounding box) circle[radius=1.25cm];}}
}

\begin{document}
\begin{tikzpicture}
\fill circle[radius=2cm];
\draw[white, line width=2pt] circle[radius=1.5cm];
\foreach \t[count=\n] in {30,90,...,330}{\node[myhex](H\n) at (\t:4){};}
\foreach \t[evaluate=\t as \s using {int(1+mod(\t,6))}, evaluate=\t as \r using {int(1+mod(\t,6))}, evaluate=\t as \q using {int(1+mod(\r+3,6))}] in {1,...,6}{\draw[thick] (H\t.corner \r)to[bend left](H\s.corner \q);}
\foreach \t/\l in {0/label1,60/label2,120/label3,180/label4,240/label5,300/label6}{\node[rotate={\t+180*(and(\t>90,\t<270))}] at (\t:3.5){\l};}
\end{tikzpicture}
\end{document} 

答案2

您可以使用更大的六边形作为框架。

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\begin{document}
\begin{tikzpicture}
\node[regular polygon, regular polygon sides=6,inner sep=2.5cm, rotate=30] (frame) {};
\node[regular polygon, regular polygon sides=6, draw, inner sep=1cm] at (frame.corner 1) {1};
\node[regular polygon, regular polygon sides=6, draw, inner sep=1cm] at (frame.corner 2) {2};
\node[regular polygon, regular polygon sides=6, draw, inner sep=1cm] at (frame.corner 3) {3};
\node[regular polygon, regular polygon sides=6, draw, inner sep=1cm] at (frame.corner 4) {4};
\node[regular polygon, regular polygon sides=6, draw, inner sep=1cm] at (frame.corner 5) {5};
\node[regular polygon, regular polygon sides=6, draw, inner sep=1cm] at (frame.corner 6) {6};
\end{tikzpicture}
\end{document} 

演示

相关内容