更新

更新

“旭日图(也称为环形图、多级饼图和径向树状图)通常用于可视化分层数据结构。”

我所寻找的并不完全是上述内容,而是它的概括。

我想为论文创建一个简单的情节。

它应该是矢量图形并且易于创建。

如果可能的话,我想在组件内添加文本。

这里至少有两个选项(见下文)。如果你明白我的意思,也许可以将其表达为某种“漩涡”……

如果我可以强调组件的重叠,即通过重叠的爆炸饼图,那就太好了。

在此处输入图片描述

答案1

我想这可以称为环形图,就像圆形谱系图一样,这个项目就是从这个谱系图发展而来的。这应该可以让你入门了。封闭环境是,onion并接受一个参数,即环的厚度(星号导致绘制 xy 轴)。该\annulus宏接受三个强制参数:层号(最内层为 0)、起始角度和终止角度,角度按逆时针指定。开头还有一个可选参数,用于填充颜色,结尾处用于文本。完整的命令可能如下所示:

\annulus[purple!20]{2}{165}{325}[more\\stuff](见下面的代码)。

这里没有什么复杂的。TiZarc函数完成大部分工作。

\documentclass{article}

\usepackage{xcolor}
\usepackage{xparse}
\usepackage{tikz}


\usetikzlibrary{calc,positioning}

%% |=====8><-----| %%

\newlength{\layerwd}
\newcounter{outermost}

%% |=====8><-----| %%

\NewDocumentEnvironment{onion}{sm}{%*= draw axes; #1: thickness of each annulus
    \begin{tikzpicture}
        \setlength{\layerwd}{#2}%
        \setcounter{outermost}{0}
        \IfBooleanT{#1}{%
            \draw[<->] (-4,0) -- (4,0);
            \draw[<->] (0,4) -- (0,-4);
        }
}{%
    \foreach \A in {0,...,\theoutermost}{\draw[thick] (0,0) circle (\A*\layerwd+\layerwd);}
    \end{tikzpicture}
}

% *=unused; [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}{\node[inner sep=0pt, %%% If there is text, print it
        text width=#3*\layerwd*3+\layerwd,
        align=center,
        rotate=\tmp-90,
        font=\footnotesize] at (\tmp:#3*\layerwd+0.5*\layerwd)
        {#6}; %% Options text, rotated, in the middle of the arc
    }%
    \ifnum\theoutermost<#3\setcounter{outermost}{#3}\fi
}

%% |=====8><-----| %%

\begin{document}

\begin{onion}*{0.25in}
    \annulus{0}{0}{90}[1]
    \annulus{0}{90}{180}[2]
    \annulus{0}{180}{270}[3]
    \annulus{0}{270}{360}[4]
    \annulus[yellow]{1}{0}{120}[Y]
    \annulus[red!20]{4}{0}{90}
    \annulus[blue!30]{3}{60}{180}
    \annulus[cyan!20]{2}{45}{130}
    \annulus[purple!20]{2}{165}{325}[more\\stuff]
\end{onion}

\end{document}

环形图

更新

创建一个环形图而不利用 Ti 似乎很奇怪Z 可以将文本放在路径上。唯一的变化是\annulus宏可以采用可选方式*将可选文本放在圆形路径上。请注意,路径上的文本不能有换行符;\\这会导致 TeX 挂起——我已经在一定程度上防范了这种可能性。

\documentclass{article}

\usepackage{xcolor}
\usepackage{xparse}
\usepackage{tikz}


\usetikzlibrary{calc,positioning}
\usetikzlibrary{decorations, decorations.text}

%% |=====8><-----| %%

\newlength{\layerwd}
\newcounter{outermost}

%% |=====8><-----| %%

\NewDocumentEnvironment{onion}{sm}{%*= draw axes; #1: thickness of each annulus
    \begin{tikzpicture}
        \setlength{\layerwd}{#2}%
        \setcounter{outermost}{0}
        \IfBooleanT{#1}{%
            \draw[<->] (-4,0) -- (4,0);
            \draw[<->] (0,4) -- (0,-4);
        }
}{%
    \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
                \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=true,
                        text=#6
                    }
                }] (0,0) circle (#3*\layerwd+0.5*\layerwd);
            \endgroup
        }%% 
        {%
            \node[inner sep=0pt, %%% If there is text, print it
            text width=#3*\layerwd*3+\layerwd,
            align=center,
            rotate=\tmp-90,
            font=\footnotesize] at (\tmp:#3*\layerwd+0.5*\layerwd)
            {#6};
        }%
    }%
    \ifnum\theoutermost<#3\setcounter{outermost}{#3}\fi
}

%% |=====8><-----| %%

\begin{document}

\begin{onion}*{0.25in}
    \annulus{0}{0}{90}[1]
    \annulus{0}{90}{180}[2]
    \annulus{0}{180}{270}[3]
    \annulus{0}{270}{360}[4]
    \annulus*[yellow]{1}{0}{120}[Y is yellow]
    \annulus*[red!20]{4}{0}{90}[This is a bunch of bla bla]
    \annulus*[blue!30]{3}{60}{180}[This is some longer text]
    \annulus[cyan!20]{2}{45}{130}
    \annulus[purple!20]{2}{165}{325}[more\\stuff]
\end{onion}

\end{document}

路径上有文字的环形图

更新 2

做了一些小改动,确保图表下半部分的文本是正面朝上的。

\documentclass{article}

\usepackage{xcolor}
\usepackage{xparse}
\usepackage{tikz}


\usetikzlibrary{calc,positioning}
\usetikzlibrary{decorations, decorations.text}

%% |=====8><-----| %%

\newlength{\layerwd}
\newcounter{outermost}

%% |=====8><-----| %%

\NewDocumentEnvironment{onion}{sm}{%*= draw axes; #1: thickness of each annulus
    \begin{tikzpicture}
        \setlength{\layerwd}{#2}%
        \setcounter{outermost}{0}
        \IfBooleanT{#1}{%
            \draw[<->] (-4,0) -- (4,0);
            \draw[<->] (0,4) -- (0,-4);
        }%
}{%
    \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=\footnotesize] at (\tmp:#3*\layerwd+0.5*\layerwd)
            {#6};
        }%
    }%
    \ifnum\theoutermost<#3\setcounter{outermost}{#3}\fi
}

%% |=====8><-----| %%

\begin{document}

\begin{onion}*{0.3in}
    \annulus{0}{0}{90}[1]
    \annulus{0}{90}{180}[2]
    \annulus{0}{180}{270}[3]
    \annulus{0}{270}{360}[4]
    \annulus*[yellow]{1}{0}{120}[Y is yellow]
    \annulus*[red!20]{4}{0}{135}[This is a bunch of bla bla]
    \annulus*[blue!30]{3}{60}{180}[This is some longer text]
    \annulus[cyan!20]{2}{45}{130}
    \annulus[white]{3}{225}{315}[Line 1\\Line 2]
    \annulus*[purple!20]{2}{165}{325}[more\\stuff]
\end{onion}

\end{document}

修正环状图

相关内容