플로팅: 회귀 트리 및 파티션

플로팅: 회귀 트리 및 파티션

Latex에서 다음 두 그래프를 재구성하려고 시도하고 있지만 아직 성공하지 못했습니다. 다음 두 패키지에 대해 들었습니다.

\사용패키지{tikz} \사용패키지{tikz-qtree}

나는 그것들을 재구성할 수 없습니다. 혹시 조언해주실 분 계신가요?

도움을 주셔서 감사합니다.

파티션 및 회귀 트리

답변1

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

책에서 직접 요구 사항의 한 부분 -http://mirrors.ibiblio.org/CTAN/graphics/pgf/contrib/tikz-qtree/tikz-qtree-manual.pdf

\documentclass[11pt]{article}
\usepackage{tikz-qtree}

\begin{tikzpicture}
\tikzset{edge from parent/.style=
{draw,
edge from parent path={(\tikzparentnode.south)
-- +(0,-8pt)
-| (\tikzchildnode)}}}
\Tree [.S [.NP [.Det the ] [.N cat ] ]
[.VP [.V sat ]
[.PP [.P on ]
[.NP [.Det the ] [.N mat ] ] ] ] ]
\end{tikzpicture}
\end{document}

편집1

다음과 같은 옵션을 추가하여 노드 이름을 이동할 수 있습니다.[\edge node[xshift=20pt,yshift=5pt]{$y$};

여기 ypp이동되었습니다

\begin{tikzpicture}
\tikzset{edge from parent/.style={draw, edge from parent path={(\tikzparentnode.south) -- +(0,-8pt) -| (\tikzchildnode)}}}

\Tree [\edge node[xshift=20pt,yshift=5pt]{$y$}; [.NP [.Det the ] [.N cat ] ]
[.VP [.V sat ]
[\edge node[xshift=30pt,yshift=5pt]{$pp$};  [.P on ]
[.NP [.Det the ] [.N mat ] ] ] ] ]
\end{tikzpicture}

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

편집2

요구 사항의 첫 번째 부분은 아래에 답변되어 있습니다. 약간의 조정이 필요합니다. 이는 2019년 1월 23일에 나온 동일한 사이트 답변에서 가져온 것입니다.https://tex.stackexchange.com/a/525323/197451

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

\documentclass[border=5pt]{standalone}
    \usepackage{pgfplots}
    \pgfplotsset{
    % use `compat' level 1.11 or higher so coordinates don't have to be
    % prefixed with `axis cs:' (any more)
    compat=1.11,
    }
    \begin{document}
    \begin{tikzpicture}[
    region/.style={
        draw=black!50,
        dashed,
    },
    Node/.style={
        midway,
        red,
    },
    declare function={
        xmin=0;
        xmax=12;
        ymin=0;
        ymax=300;
    },
    ]
    \begin{axis}[hide axis,
        xlabel={},
        ylabel={},
        xmin=xmin,
        xmax=xmax,
        ymin=ymin,
        ymax=ymax,
        axis background/.style={},
        extra x ticks={},
        extra y ticks={},
        title=title,
        ]
                    \draw [region,fill=brown!40] (xmin,ymin) rectangle (8,ymax)  node [Node, xshift=-55, yshift=-76] {68\%};

        \draw [region,fill=blue!40] (8,ymin)  rectangle (10,50)  node [Node, xshift=-10, yshift=-9] {5\%};
        \draw [region,fill=red!40] (10,ymin)   rectangle (xmax,50)  node [Node, xshift=-10, yshift=-9] {5\%};
        \draw [region,fill=gray!40] (8,50)   rectangle (xmax,ymax) node [Node, xshift=-24, yshift=-64] {22\%};

        \end{axis}
\end{tikzpicture}
\end{document}

동일한 코드를 적용한 후 OP는 다음을 얻을 수 있습니다 ---

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

관련 정보