Bordaigorl의 원형 차트 크기

Bordaigorl의 원형 차트 크기

나는 다음과 같은 훌륭한 원형 차트 코드를 사용하고 있습니다.막대 및 원형 차트를 그리는 방법코드는 다음과 같습니다.보르다이골.

동일한 환경에서 크기가 다른 두 개의 원형 차트를 갖는 것이 어떻게 가능한지 누구나 알 수 있는지 궁금합니다.

이를 담당하는 코드 부분은 원형 차트 함수를 호출할 때 "규모"입니다.

\begin{tikzpicture}
[
    pie chart,
    slice type={g}{giallo},
    slice type={A}{rosso},
    slice type={B}{blu},
    pie values/.style={font={\small}},
    scale=2
]

    \pie{t=1, A in power}{66/g,34/A}
    \pie[xshift=2.2cm]%
        {t=2, B in power}{33/g,33/B}
\end{tikzpicture}

내 질문은: 예를 들어 를 사용하여 하나 scale=2와 를 사용하여 다른 두 가지 "유형"의 파이를 만드는 방법을 아는 사람이 있습니까 ?scale=2.5

이해를 돕기 위해 작성한 전체 코드를 기반으로 MWE를 게시하겠습니다.보르다이골여기. 내가 원하는 것은 왼쪽 원형 차트를 한 눈금으로, 오른쪽 원형 차트를 다른 눈금으로 갖는 것입니다.나는 이 코드를 디자인한 사람이 아니며 크레딧을 제공해야 합니다.보르다이골:

\documentclass[border=10pt,multi,tikz]{standalone}
\definecolor{rosso}{RGB}{220,57,18}
\definecolor{giallo}{RGB}{255,153,0}
\definecolor{blu}{RGB}{102,140,217}
\definecolor{verde}{RGB}{16,150,24}
\definecolor{viola}{RGB}{153,0,153}

\makeatletter

\tikzstyle{chart}=[
    legend label/.style={font={\scriptsize},anchor=west,align=left},
    legend box/.style={rectangle, draw, minimum size=5pt},
    axis/.style={black,semithick,->},
    axis label/.style={anchor=east,font={\tiny}},
]

\tikzstyle{bar chart}=[
    chart,
    bar width/.code={
        \pgfmathparse{##1/2}
        \global\let\bar@w\pgfmathresult
    },
    bar/.style={very thick, draw=white},
    bar label/.style={font={\bf\small},anchor=north},
    bar value/.style={font={\footnotesize}},
    bar width=.75,
]

\tikzstyle{pie chart}=[
    chart,
    slice/.style={line cap=round, line join=round, very thick,draw=white},
    pie title/.style={font={\bf}},
    slice type/.style 2 args={
        ##1/.style={fill=##2},
        values of ##1/.style={}
    }
]

\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}


\newcommand{\pie}[3][]{
    \begin{scope}[#1]
    \pgfmathsetmacro{\curA}{90}
    \pgfmathsetmacro{\r}{1}
    \def\c{(0,0)}
    \node[pie title] at (90:1.3) {#2};
    \foreach \v/\s in{#3}{
        \pgfmathsetmacro{\deltaA}{\v/100*360}
        \pgfmathsetmacro{\nextA}{\curA + \deltaA}
        \pgfmathsetmacro{\midA}{(\curA+\nextA)/2}

        \path[slice,\s] \c
            -- +(\curA:\r)
            arc (\curA:\nextA:\r)
            -- cycle;
        \pgfmathsetmacro{\d}{max((\deltaA * -(.5/50) + 1) , .5)}

        \begin{pgfonlayer}{foreground}
        \path \c -- node[pos=\d,pie values,values of \s]{$\v\%$} +(\midA:\r);
        \end{pgfonlayer}

        \global\let\curA\nextA
    }
    \end{scope}
}

\newcommand{\legend}[2][]{
    \begin{scope}[#1]
    \path
        \foreach \n/\s in {#2}
            {
                  ++(0,-10pt) node[\s,legend box] {} +(5pt,0) node[legend label] {\n}
            }
    ;
    \end{scope}
}
\begin{document}
\begin{tikzpicture}
[
    pie chart,
    slice type={g}{giallo},
    slice type={A}{rosso},
    slice type={B}{blu},
    pie values/.style={font={\small}},
    scale=2
]

    \pie{1}{66/g,34/A}
    \pie[xshift=2.2cm]%
        {2}{33.3/g,33.3/B,33.3/A}
\end{tikzpicture}
\end{document}

그것이 당연한 질문이라면 사과드립니다. 나는 두 가지 다른 방법으로 시도했지만 모두 성공하지 못했습니다.

  1. 나는 tikz의 서문에서 스케일을 제거하려고 시도했고 파이 함수를 호출할 때 scale=2를 추가했습니다.\pie[xshift=2.2cm, scale=2]{2}{33.3/g,33.3/B,33.3/A}
  2. 나는 또한 문서의 서문에 두 개의 함수(pie1과 다른 파이2)를 만들려고 했습니다. 코드가 컴파일되지 않습니다

감사합니다!

답변1

환경 을 사용하십시오 scope. 즉

\begin{scope}[scale=2,xshift=2.2cm]
    \pie{2}{33.3/g,33.3/B,33.3/A}
\end{scope}

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

\documentclass[border=10pt,multi,tikz]{standalone}
\definecolor{rosso}{RGB}{220,57,18}
\definecolor{giallo}{RGB}{255,153,0}
\definecolor{blu}{RGB}{102,140,217}
\definecolor{verde}{RGB}{16,150,24}
\definecolor{viola}{RGB}{153,0,153}

\makeatletter

\tikzstyle{chart}=[
    legend label/.style={font={\scriptsize},anchor=west,align=left},
    legend box/.style={rectangle, draw, minimum size=5pt},
    axis/.style={black,semithick,->},
    axis label/.style={anchor=east,font={\tiny}},
]

\tikzstyle{bar chart}=[
    chart,
    bar width/.code={
        \pgfmathparse{##1/2}
        \global\let\bar@w\pgfmathresult
    },
    bar/.style={very thick, draw=white},
    bar label/.style={font={\bf\small},anchor=north},
    bar value/.style={font={\footnotesize}},
    bar width=.75,
]

\tikzstyle{pie chart}=[
    chart,
    slice/.style={line cap=round, line join=round, very thick,draw=white},
    pie title/.style={font={\bf}},
    slice type/.style 2 args={
        ##1/.style={fill=##2},
        values of ##1/.style={}
    }
]

\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}


\newcommand{\pie}[3][]{
    \begin{scope}[#1]
    \pgfmathsetmacro{\curA}{90}
    \pgfmathsetmacro{\r}{1}
    \def\c{(0,0)}
    \node[pie title] at (90:1.3) {#2};
    \foreach \v/\s in{#3}{
        \pgfmathsetmacro{\deltaA}{\v/100*360}
        \pgfmathsetmacro{\nextA}{\curA + \deltaA}
        \pgfmathsetmacro{\midA}{(\curA+\nextA)/2}

        \path[slice,\s] \c
            -- +(\curA:\r)
            arc (\curA:\nextA:\r)
            -- cycle;
        \pgfmathsetmacro{\d}{max((\deltaA * -(.5/50) + 1) , .5)}

        \begin{pgfonlayer}{foreground}
        \path \c -- node[pos=\d,pie values,values of \s]{$\v\%$} +(\midA:\r);
        \end{pgfonlayer}

        \global\let\curA\nextA
    }
    \end{scope}
}

\newcommand{\legend}[2][]{
    \begin{scope}[#1]
    \path
        \foreach \n/\s in {#2}
            {
                  ++(0,-10pt) node[\s,legend box] {} +(5pt,0) node[legend label] {\n}
            }
    ;
    \end{scope}
}
\begin{document}
\begin{tikzpicture}
[
    pie chart,
    slice type={g}{giallo},
    slice type={A}{rosso},
    slice type={B}{blu},
    pie values/.style={font={\small}},
%    scale=2
]

    \pie{1}{66/g,34/A}
\begin{scope}[scale=2,xshift=2.2cm]
    \pie{2}{33.3/g,33.3/B,33.3/A}
\end{scope}
\end{tikzpicture}
\end{document}

답변2

실제로 \pie명령은 이미 범위 환경의 경로를 래핑하므로 다음을 수행할 수 있습니다.

\pie{1}{66/g,34/A}
\pie[xshift=4cm,scale=2]%
    {2}{33.3/g,33.3/B,33.3/A}

생산하는

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

그건 그렇고, 신용 주셔서 감사합니다;)

관련 정보