向绘图中添加附加曲线

向绘图中添加附加曲线

你能帮我得到这个情节吗?我取得了一些进展,但还不够。

期望输出: 在此处输入图片描述

实际产量: 在此处输入图片描述

梅威瑟:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usepackage{lmodern}
\usepackage{microtype}
\begin{document}
    \begin{tikzpicture}[>=stealth']
        % main diagram
        \draw[thick,<->] (0,5) |-
        node[rotate=90,above,pos=0.25]{\scshape \scriptsize model prediction error}
        node[below,pos=0.75]{\scshape\scriptsize model complexity}
        (8,0);
        \draw[thick,->] (0.3,4) .. controls +(2,-4) and +(-4,0.2) .. (7.8,0.6)
        node[below,font=\scriptsize]{Training error};
        \draw[thick,->] (0.5,4.3) .. controls +(2,-3.8) and +(-2,-3.8) .. (7.8,4.3)
        node[above,align=center,font=\scriptsize]{\scshape \tiny prediciton error\\ \scshape \tiny for new data};
%       \draw[thick,<->,black] (7.5,0.8) -- node[rotate=90,above,font=\scriptsize]{\scshape \tiny optimism} +(0,2.5);
        \draw[thick,->] (0.3,0.5) .. controls +(2,-.3) and +(-2,-1.8) .. (7.8,2.3);
        % upper left
        \begin{scope}[shift={(0,5.5)}]
            \draw[thick,<->] (0,1.5) |-
            node[rotate=90,above,pos=0.25,black,font=\scshape \tiny]{happiness}
            node[below,pos=0.75,black,font=\tiny](w1){\scshape wealth}
            (2.4,0);
            \draw[thick,dotted] (w1) -- +(0,-5.2) node{\tiny$\circ$};
            \foreach \x/\y in {0.2/0.5,0.4/0.2,0.6/0.9,0.8/1.1,1.0/1.4,1.3/1.2,1.6/1.1,1.9/1.3} {
                \draw[thick](\x,\y) node{\tiny \textbf{x}};
            }
            \draw[thick,densely dashed,gray] (0.1,0.3) -- (1.8,1.5);
        \end{scope}
        % upper middle
        \begin{scope}[shift={(2.8,5.5)}]
            \draw[thick,<->] (0,1.5) |-
            node[below,pos=0.75,black,font=\tiny](w2){\scshape wealth}
            (2.4,0);
            \draw[thick,dotted] (w2) -- +(0,-5.2) node{\tiny$\circ$};
            \foreach \x/\y in {0.2/0.5,0.4/0.2,0.6/0.9,0.8/1.1,1.0/1.4,1.3/1.2,1.6/1.1,1.9/1.3} {
                \draw[thick](\x,\y) node{\tiny \textbf{x}};
            }
            \draw[thick,densely dashed,gray] (0.3,0.2) .. controls +(0.2,0.6) and +(-1.8,0) .. (2.2,1.3);
        \end{scope}
        % upper right
        \begin{scope}[shift={(5.6,5.5)}]
            \draw[thick,<->] (0,1.5) |-
            node[below,pos=0.75,black,font=\tiny](w3){\scshape wealth}
            (2.4,0);
            \draw[thick,dotted] (w3) -- +(0,-5.2) node{\tiny$\circ$};
            \foreach \x/\y[count=\i,remember=\x as \lastx,remember=\y as \lasty] in
            {0.2/0.5,0.4/0.2,0.6/0.9,0.8/1.1,1.0/1.4,1.3/1.2,1.6/1.1,1.9/1.3} {
                \draw (\x,\y) node{\tiny \textbf{x}};
                \ifnum\i>1\relax
                \draw[thick,densely dashed,gray] (\lastx,\lasty) -- (\x,\y);
                \fi
            }
        \end{scope}
    \end{tikzpicture}
\end{document}

相关内容