
Ich habe die Hilfe vonWie erstelle ich ein Sunburst-Diagramm in Latex?und habe es an meine Anforderungen für die Erstellung eines Sunburst-Diagramms angepasst. Ich muss den gesamten Text darin fett formatieren und, wenn möglich, die Textgröße darin erhöhen. Hier ist mein MWE.
\documentclass[border=0.05in]{standalone}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{xparse}
\usepackage{tikz}
\definecolor{pear}{rgb}{0.82, 0.89, 0.19}
\definecolor{lavender}{rgb}{0.71, 0.49, 0.86}
\usetikzlibrary{calc,positioning}
\usetikzlibrary{decorations, decorations.text}
\newlength{\layerwd}
\newcounter{outermost}
\NewDocumentEnvironment{onion}{sm}{%*= draw axes; #1: thickness of each annulus
\begin{tikzpicture}
\setlength{\layerwd}{#2}%
\setcounter{outermost}{0}
}{%
\foreach \A in {0,...,\theoutermost}{\draw[thick,] (0,0) circle (\A*\layerwd+\layerwd);}
\end{tikzpicture}
}
% *=text on a circular path; [optional fill color]; #3 layer;
% #4 start angle; #5 stop angle; #6 [optional text]
%% angles are counterclockwise in degrees
\NewDocumentCommand{\annulus}{sO{lightgray}mmmo}{%
\filldraw[thick,fill=#2,] (#4:#3*\layerwd) %% start here
arc [radius=#3*\layerwd, start angle=#4, delta angle=#5-#4] %% inner arc
-- (#5:#3*\layerwd+\layerwd) %% move out
arc [radius=#3*\layerwd+\layerwd, start angle=#5, delta angle=#4-#5,] %% outer arc
-- cycle; %% Back to the beginnning
\pgfmathsetmacro{\tmp}{(#5-#4)/2 +#4} %% Locate the middle of the arc
\IfNoValueF{#6}{%
\IfBooleanTF{#1}
{%
\begingroup
%% text is always rightside-up:
\pgfmathsetmacro{\rpTF}{ifthenelse(\tmp>180,"false","true")}
\def\\{\space} %% A safety precaution, \\ = space on decorated text
\path[rotate=\tmp-180,postaction={
decorate,
decoration={
text along path,
raise=-3pt,
text align={align=center},
reverse path=\rpTF,
text=#6
}
}] (0,0) circle (#3*\layerwd+0.5*\layerwd);
\endgroup
}%%
{%
\pgfmathsetmacro{\rpTF}{ifthenelse(\tmp>180,\tmp+90,\tmp-90)}
\node[inner sep=0pt, %%% If there is text, print it
text width=#3*\layerwd*3+\layerwd,
align=center,
rotate=\rpTF,
font=\normalsize] at (\tmp:#3*\layerwd+0.5*\layerwd)
{#6};
}%
}%
\ifnum\theoutermost<#3\setcounter{outermost}{#3}\fi
}
\begin{document}
\begin{onion}*{0.6in}
\draw[fill=red!20,thick] (0,0) circle (1.53cm);
\node[color=red,thick,font=\bfseries] at (0,0) {My research};
\annulus*[pear]{1}{0}{180}[Materials for composites]
\annulus*[pear!80]{2}{0}{180}[Working through trial and errors to find parameters]
\annulus*[pear!60]{3}{0}{180}[Conditions associated with pre and post heat treatment]
\annulus*[pear!40]{4}{20}{70}[Mechanical]
\annulus*[pear!40]{4}{0}{20}[Physical]
\annulus*[pear!40]{4}{70}{100}[Tribological]
\annulus*[pear!40]{4}{100}{150}[Microstructure(OM/SEM/TEM)]
\annulus*[pear!40]{4}{150}{180}[XRD]
\annulus[pear!25]{5}{150}{180}[2($\theta$) and \\Bulk texture]
\annulus[pear!25]{5}{100}{150}[Composites{,}\\Fracture{,}\\Wear track/debris]
\annulus*[pear!25]{5}{70}{100}[Wear rate/COF]
\annulus[pear!25]{5}{20}{40}[Hardness (Hv)]
\annulus[pear!25]{5}{0}{20}[Density]
\annulus[pear!25]{5}{40}{70}[Tensile (MPa)\\Yield (MPa)\\Elongation ($\delta$)]
\annulus*[lavender!65]{1}{180}{360}[Materials for composites]
\annulus*[lavender!55]{2}{180}{360}[Working through trial and errors to find parameters]
\annulus*[lavender!45]{3}{180}{360}[Conditions associated with pre and post heat treatment]
\annulus*[lavender!35]{4}{180}{200}[Physical]
\annulus*[lavender!35]{4}{200}{250}[Mechanical]
\annulus*[lavender!35]{4}{250}{280}[Tribological]
\annulus*[lavender!35]{4}{280}{330}[Microstructure(OM/SEM/TEM)]
\annulus*[lavender!35]{4}{330}{360}[XRD]
\annulus[lavender!25]{5}{180}{200}[Density]
\annulus[lavender!25]{5}{200}{220}[Hardness (Hv)]
\annulus[lavender!25]{5}{220}{250}[Tensile (MPa)\\Yield (MPa)\\Elongation ($\delta$)]
\annulus*[lavender!25]{5}{250}{280}[Wear rate/COF]
\annulus[lavender!25]{5}{280}{330}[Composites{,}\\Fracture{,}\\Wear track/debris]
\annulus[lavender!25]{5}{330}{360}[2($\theta$) and \\Bulk texture]
\end{onion}
\end{document}
Es wird die folgende Ausgabe erzeugt:
Antwort1
Um den Schriftstil zu ändern, müssen Sie dieTextEigentum innerhalb der\RingDefinition. Konkret müssen Sie Folgendes ändern:
decoration={
text along path,
raise=-3pt,
text align={align=center},
reverse path=\rpTF,
text=#6 % <-------------- HERE!
}
dazu:
text={|\customannfont|#6}
und das:
\node[inner sep=0pt, %%% If there is text, print it
text width=#3*\layerwd*3+\layerwd,
align=center,
rotate=\rpTF,
font=\normalsize] at (\tmp:#3*\layerwd+0.5*\layerwd) % <-------------- HERE!
{#6};
dazu:
font=\customannfont] at (\tmp:#3*\layerwd+0.5*\layerwd)
Hinweis: Anstatt \customannfont zu verwenden, können Sie den Stil Ihrer Schriftart einfach wie folgt schreiben:
%%% code before
text={|\bfseries\fontsize{10}{0}\selectfont|#6}
%%% other code
font=\fontsize{10}{0}\selectfont
um die Schrift 10pt und fett zu machen. Ich empfehle jedoch, Ihren Stil vor dem\RingDefinition, sodass Sie sie an beiden Stellen im Code ändern können, indem Sie sie nur einmal ändern, und zwar wie folgt:
\newcommand{\customannfont}{\fontsize{10}{0}\selectfont}
Hier ist der vollständige Code, um die Schrift fett und größer zu machen:
\documentclass[border=0.05in]{standalone}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{xparse}
\usepackage{tikz}
\definecolor{pear}{rgb}{0.82, 0.89, 0.19}
\definecolor{lavender}{rgb}{0.71, 0.49, 0.86}
\usetikzlibrary{calc,positioning}
\usetikzlibrary{decorations, decorations.text}
\newlength{\layerwd}
\newcounter{outermost}
\NewDocumentEnvironment{onion}{sm}{%*= draw axes; #1: thickness of each annulus
\begin{tikzpicture}
\setlength{\layerwd}{#2}%
\setcounter{outermost}{0}
}{%
\foreach \A in {0,...,\theoutermost}{\draw[thick,] (0,0) circle (\A*\layerwd+\layerwd);}
\end{tikzpicture}
}
% define your custom font style
\newcommand{\customannfont}{\bfseries\fontsize{10}{0}\selectfont}
% *=text on a circular path; [optional fill color]; #3 layer;
% #4 start angle; #5 stop angle; #6 [optional text]
%% angles are counterclockwise in degrees
\NewDocumentCommand{\annulus}{sO{lightgray}mmmo}{%
\filldraw[thick,fill=#2,] (#4:#3*\layerwd) %% start here
arc [radius=#3*\layerwd, start angle=#4, delta angle=#5-#4] %% inner arc
-- (#5:#3*\layerwd+\layerwd) %% move out
arc [radius=#3*\layerwd+\layerwd, start angle=#5, delta angle=#4-#5,] %% outer arc
-- cycle; %% Back to the beginnning
\pgfmathsetmacro{\tmp}{(#5-#4)/2 +#4} %% Locate the middle of the arc
\IfNoValueF{#6}{%
\IfBooleanTF{#1}
{%
\begingroup
%% text is always rightside-up:
\pgfmathsetmacro{\rpTF}{ifthenelse(\tmp>180,"false","true")}
\def\\{\space} %% A safety precaution, \\ = space on decorated text
\path[rotate=\tmp-180,postaction={
decorate,
decoration={
text along path,
raise=-3pt,
text align={align=center},
reverse path=\rpTF,
text={|\customannfont|#6}
}
}] (0,0) circle (#3*\layerwd+0.5*\layerwd);
\endgroup
}%%
{%
\pgfmathsetmacro{\rpTF}{ifthenelse(\tmp>180,\tmp+90,\tmp-90)}
\node[inner sep=0pt, %%% If there is text, print it
text width=#3*\layerwd*3+\layerwd,
align=center,
rotate=\rpTF,
font=\customannfont] at (\tmp:#3*\layerwd+0.5*\layerwd)
{#6};
}%
}%
\ifnum\theoutermost<#3\setcounter{outermost}{#3}\fi
}
\begin{document}
\begin{onion}*{0.6in}
\draw[fill=red!20,thick] (0,0) circle (1.53cm);
\node[color=red,thick,font=\bfseries] at (0,0) {My research};
\annulus*[pear]{1}{0}{180}[Materials for composites]
\annulus*[pear!80]{2}{0}{180}[Working through trial and errors to find parameters]
\annulus*[pear!60]{3}{0}{180}[Conditions associated with pre and post heat treatment]
\annulus*[pear!40]{4}{20}{70}[Mechanical]
\annulus*[pear!40]{4}{0}{20}[Physical]
\annulus*[pear!40]{4}{70}{100}[Tribological]
\annulus*[pear!40]{4}{100}{150}[Microstructure(OM/SEM/TEM)]
\annulus*[pear!40]{4}{150}{180}[XRD]
\annulus[pear!25]{5}{150}{180}[2($\theta$) and \\Bulk texture]
\annulus[pear!25]{5}{100}{150}[Composites{,}\\Fracture{,}\\Wear track/debris]
\annulus*[pear!25]{5}{70}{100}[Wear rate/COF]
\annulus[pear!25]{5}{20}{40}[Hardness (Hv)]
\annulus[pear!25]{5}{0}{20}[Density]
\annulus[pear!25]{5}{40}{70}[Tensile (MPa)\\Yield (MPa)\\Elongation ($\delta$)]
\annulus*[lavender!65]{1}{180}{360}[Materials for composites]
\annulus*[lavender!55]{2}{180}{360}[Working through trial and errors to find parameters]
\annulus*[lavender!45]{3}{180}{360}[Conditions associated with pre and post heat treatment]
\annulus*[lavender!35]{4}{180}{200}[Physical]
\annulus*[lavender!35]{4}{200}{250}[Mechanical]
\annulus*[lavender!35]{4}{250}{280}[Tribological]
\annulus*[lavender!35]{4}{280}{330}[Microstructure(OM/SEM/TEM)]
\annulus*[lavender!35]{4}{330}{360}[XRD]
\annulus[lavender!25]{5}{180}{200}[Density]
\annulus[lavender!25]{5}{200}{220}[Hardness (Hv)]
\annulus[lavender!25]{5}{220}{250}[Tensile (MPa)\\Yield (MPa)\\Elongation ($\delta$)]
\annulus*[lavender!25]{5}{250}{280}[Wear rate/COF]
\annulus[lavender!25]{5}{280}{330}[Composites{,}\\Fracture{,}\\Wear track/debris]
\annulus[lavender!25]{5}{330}{360}[2($\theta$) and \\Bulk texture]
\end{onion}
\end{document}
Antwort2
Die Schriftart kann mit \bfseries
und angegeben werden \large
.
Der Code kann vereinfacht werden durchRaddiagrammPaket, das ich geschrieben habe.
Der Text in den Bögen wird mit der Taste angegeben arc data
. Hier \\
kann verwendet werden, um den Text auf mehrere Zeilen aufzuteilen. Die Richtung dieses Textes hängt vom Winkel der Bogenmitte ab, der mit angegeben wird und \WCmidangle
in der Taste verwendet wird arc data dir
. Mit wird dieser Text im Bogen zentriert arc data pos=0.5
.
\documentclass[border=6pt]{standalone}
\usepackage{wheelchart}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}[scale=1.2]
\bfseries\large
\definecolor{lavender}{rgb}{0.71, 0.49, 0.86}
\definecolor{pear}{rgb}{0.82, 0.89, 0.19}
\pgfkeys{
/wheelchart,
arc data=\WCvarB,
arc data dir={\WCmidangle<180?1:-1},
arc data expand=f,
arc data pos=0.5,
data=,
slices style={fill=\WCcolor,draw=black,thick},
total angle=180
}
\fill[red!20] (0,0) circle[radius=1.5] node[red] {My research};
\foreach\WCstartangle/\WCcolorA/\WCcolorB/\WCcolorC/\WCcolorD/\WCcolorE in {%
180/pear/pear!80/pear!60/pear!40/pear!25,
0/lavender!65/lavender!55/lavender!45/lavender!35/lavender!25%
}{
\pgfkeys{
/wheelchart,
start angle=\WCstartangle
}
\edef\WCcolor{\WCcolorA}
\wheelchart[
radius={1.5}{3}
]{%
1/Materials for composites%
}
\edef\WCcolor{\WCcolorB}
\wheelchart[
radius={3}{4.5}
]{%
1/Working through trial and errors to find parameters%
}
\edef\WCcolor{\WCcolorC}
\wheelchart[
radius={4.5}{6}
]{%
1/Conditions associated with pre and post heat treatment%
}
\edef\WCcolor{\WCcolorD}
\wheelchart[
radius={6}{7.5}
]{%
30/XRD,
50/{Microstructure (OM/SEM/TEM)},
30/Tribological,
50/Mechanical,
20/Physical%
}
\edef\WCcolor{\WCcolorE}
\wheelchart[
radius={7.5}{9}
]{%
30/$2({\theta})$ and\\Bulk texture,
50/{Composites,\\Fracture,\\Wear track/debris},
30/{Wear rate/COF},
30/Tensile (MPa)\\Yield (MPa)\\Elongation (${\delta}$),
20/Hardness (Hv),
20/Density%
}
}
\end{tikzpicture}
\end{document}