請任何幫助。先感謝您。
編輯:我試圖修改這個乳膠,但有庫存:
\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}