更改 TikZ 图表中的文本方向

更改 TikZ 图表中的文本方向

我正在使用模板TikZ代码来创建下图。 在此处输入图片描述

以下是代码:

\documentclass[border=2mm]{standalone}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart}
%\newcommand{\cc}{c\nolinebreak\hspace{-.05em}\raisebox{.2ex}{\tiny\bf +}\nolinebreak\hspace{-.10em}\raisebox{.2ex}{\tiny\bf +}}

\newcommand{\vardonut}[1]{
\newcounter{num}
\foreach \content/\size/\colour in {#1}
    \stepcounter{num};
\foreach \content/\size/\colour [count=\i] in {#1}{
    \draw[white,very thick,top color=\colour!80!black, bottom color=\colour, shading angle={-90+360/\thenum/2+(\i-1)*360/\thenum}] 
    ({2*cos((\i-1)*360/\thenum)},{2*sin((\i-1)*360/\thenum)}) arc[radius = 2, start angle={(\i-1)*360/\thenum}, delta angle=360/\thenum] --
    ({(2+\size)*cos(\i*360/\thenum)},{(2+\size)*sin(\i*360/\thenum)}) arc[radius = {2+\size}, start angle={\i*360/\thenum}, delta angle=-360/\thenum] -- 
    cycle;
    \node[Black,font=\Large] at ({(\i-1)*360/\thenum+360/\thenum/2}:{\size/2+2}) {\content  };
 }
}

\begin{document}
\begin{tikzpicture}[every text node part/.style={align=center}]
    \vardonut{AAAAAA\small({bbbbbbb})/6/YellowOrange!50!, CCCCCCC/5/Salmon, DDDDDD/2/SkyBlue!50!, EEEEEE/2/Aquamarine,FFFFFF/5/Yellow, GGGGGG\textsuperscript{\textregistered} \small{Notes}/4/Magenta!50!, HHH/2/Apricot,  \large{III }/3/ForestGreen!50!,JJJJ/6/Cyan,\LaTeX/6/Yellow}

\end{tikzpicture}
\end{document}    

我怎样才能改变text角度并且方向从中心到外部,并且在使用长文本的情况下将文本分成两行?

答案1

像这样吗?

\documentclass[border=2mm]{standalone}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart}
%\newcommand{\cc}{c\nolinebreak\hspace{-.05em}\raisebox{.2ex}{\tiny\bf +}\nolinebreak\hspace{-.10em}\raisebox{.2ex}{\tiny\bf +}}

\newcommand{\vardonut}[1]{
\newcounter{num}
\foreach \content/\size/\colour in {#1}
    \stepcounter{num};
\foreach \content/\size/\colour [count=\i] in {#1}{
    \draw[white,very thick,top color=\colour!80!black, bottom color=\colour, shading angle={-90+360/\thenum/2+(\i-1)*360/\thenum}] 
    ({2*cos((\i-1)*360/\thenum)},{2*sin((\i-1)*360/\thenum)}) arc[radius = 2, start angle={(\i-1)*360/\thenum}, delta angle=360/\thenum] --
    ({(2+\size)*cos(\i*360/\thenum)},{(2+\size)*sin(\i*360/\thenum)}) arc[radius = {2+\size}, start angle={\i*360/\thenum}, delta angle=-360/\thenum] -- 
    cycle;
    \node[Black,font=\Large,rotate=(\i-1)*360/\thenum+360/\thenum/2,text
    width=0.8*\size cm,align=left,anchor=west] at
    ({(\i-1)*360/\thenum+360/\thenum/2}:{2}) {\content  };
 }
}

\begin{document}
\begin{tikzpicture}[every text node part/.style={align=center}]
    \vardonut{AAA AAA\small({bbbbbbb})/6/YellowOrange!50!, CCCC CCC/5/Salmon,
    DDD DDD/2/SkyBlue!50!, EEE EEE/2/Aquamarine,FFFFFF/5/Yellow, GGG GGG\textsuperscript{\textregistered} \small{Notes}/4/Magenta!50!, HHH/2/Apricot,  \large{III }/3/ForestGreen!50!,JJJJ/6/Cyan,\LaTeX/6/Yellow}

\end{tikzpicture}
\end{document}    

在此处输入图片描述

答案2

轮图我写的包,可以使用。

外半径由第一个变量决定,表示为\WCvarA。最初,\WCvarA用于键value。此初始设置被设置 所取代value=1

请注意,问题中有\small{Notes}。最好这样写{\small Notes},例如在\bfseries 加粗程度超出预期

在此处输入图片描述

\documentclass[border=6pt,dvipsnames]{standalone}
\usepackage{wheelchart}
\begin{document}
\begin{tikzpicture}
\wheelchart[
  counterclockwise,
  data=,
  gap=0.02,
  radius={1}{\WCvarA},
  slices style={
    bottom color=\WCvarB,
    top color={\WCvarB!80!black},
    shading angle={\WCmidangle-90}
  },
  start angle=0,
  value=1,
  wheel data=\WCvarC,
  wheel data pos=0.5,
  wheel data style={rotate=\WCmidangle}
]{%
  6/YellowOrange!50!/AAA AAA\\{\small(bbbbbbb)},
  5/Salmon/CCCC\\CCC,
  2/SkyBlue!50!/DDD\\DDD,
  2/Aquamarine/EEE\\EEE,
  5/Yellow/FFF\\FFF,
  4/Magenta!50!/GGG\\GGG\textsuperscript{\textregistered}\\{\small Notes},
  2/Apricot/HHH,
  3/ForestGreen!50!/{\large III},
  6/Cyan/JJJJ,
  6/Yellow/\LaTeX%
}
\end{tikzpicture}
\end{document}

相关内容