업데이트

업데이트

"선버스트 차트(링 차트, 다단계 원형 차트, 방사형 트리맵이라고도 함)는 일반적으로 계층적 데이터 구조를 시각화하는 데 사용됩니다."

내가 찾고 있는 것은 위의 내용이 아니라 이를 일반화한 것입니다.

나는 종이에 대한 간단한 플롯을 만들고 싶습니다.

벡터 그래픽이어야 하며 만들기 쉬워야 합니다.

가능하다면 구성 요소 내부에 텍스트를 추가하고 싶습니다.

여기에는 최소한 두 가지 옵션이 있습니다(아래 참조). 무슨 뜻인지 알면 이것을 일종의 '소용돌이'로 표현하는 것도 가능할 것 같습니다...

또한 구성요소의 중첩을 강조할 수 있다면 좋을 것입니다. 즉, 중첩이 있는 폭발적인 원형 차트를 사용하는 것입니다.

여기에 이미지 설명을 입력하세요

답변1

이건 이라고 할 수 있을 것 같아요환상 그래프, 오히려 원형 가계도처럼 이 프로젝트가 성장했습니다. 이제 시작해야 합니다. 둘러싸는 환경은 onion고리의 두께라는 하나의 인수를 취합니다(별은 xy 축을 그리게 합니다). 매크로 \annulus는 레이어 번호(가장 안쪽은 0), 시작 각도 및 끝 각도, 시계 반대 방향으로 지정되는 각도 등 세 가지 필수 인수를 사용합니다. 채우기 색상의 시작 부분과 텍스트의 끝 부분에도 선택적 인수가 있습니다. 전체 명령은 다음과 같습니다.

\annulus[purple!20]{2}{165}{325}[more\\stuff](아래 코드 참조).

여기에는 그다지 복잡한 것이 없습니다. 티케이Z arc함수는 대부분의 작업을 수행합니다.

\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}

수정된 환상 그래프

관련 정보