请提供任何帮助。提前谢谢您。
编辑:我试图修改这个乳胶,但得到了库存:
\usetikzlibrary{arrows.meta}
\usetikzlibrary{decorations.text}
\begin{tikzpicture}[scale=0.85]
\foreach \X [count=\Y starting from 2] in
{A,B,C}
{\draw (-\Y,-\Y/2) circle ({1.5*\Y} and \Y);
\path[decoration={text along path,
text={classes |\itshape|\X},text align=center,raise=0.2em},decorate] (-\Y,-\Y/2) +(-1.5*\Y,0) arc(180:360:{1.5*\Y} and \Y);
}
\draw ([xshift=-0.5cm,yshift=-0.5cm]current bounding box.south west)
rectangle ([xshift=0.5cm,yshift=0.5cm]current bounding box.north east);
\node[anchor=south] at (current bounding box.north) {\textbf{Three classes}};
\end{tikzpicture}
答案1
\foreach
根据您提供的代码,使用循环的一个非常简单的解决方案可能是:
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=0.5]
\foreach \x [count=\y] in {A,B,C} {
\draw (0,{-\y}) circle[radius=\y];
\node at (0,{-2*\y+1}) {\x};
}
\end{tikzpicture}
\end{document}
但请注意,如果您想用某种颜色填充三个圆圈,您可能需要从最大到最小绘制这三个圆圈,否则最大的圆圈将覆盖其他圆圈:
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=0.5]
\foreach \x/\z [count=\y] in {C/yellow,B/orange,A/red} {
\draw[fill=\z] (0,{\y-4}) circle[radius={4-\y}];
\node at (0,{-2*(4-\y)+1}) {\x};
}
\end{tikzpicture}
\end{document}