答案1
像这样。
% Adapted from https://raw.githubusercontent.com/MartinThoma/LaTeX-examples/master/tikz/bias-variance/bias-variance.tex
\documentclass[border=2pt]{standalone}
\usepackage[dvipsnames]{xcolor}
\usepackage{pgfplots}
\usepackage{sansmath}
\usetikzlibrary{arrows.meta,bending}
\tikzset{>=stealth,
OptimumStyle/.style={align=center,anchor=east,rotate=90,font=\sffamily\scriptsize}
}
\pgfplotsset{compat=1.17,
samples=101,
axis lines = left,
every axis plot/.append style={line width=2pt},
}
\begin{document}
\begin{tikzpicture}[font=\sffamily\sansmath]
\begin{axis}[
xmin= 0,
xmax= 2,
ymin= 0,
ymax= 2,
xlabel=Model Complexity,
ylabel=Error,
ticks=none,
xticklabels={\empty},
yticklabels={\empty}
]
\addplot[domain=0.2:1.9,Maroon,<->] {1/(x+0.3)-0.2}; %Bias
\addplot[domain=0.2:1.9,TealBlue,<->] {0.12*e^(1.40*x)}; %Variance
\addplot[domain=0.39:1.61,black,<->] {3*(x-2)*x+3.8}; %Total error
\addplot[dotted,thin] coordinates {(1,0) (1,2)}; %Optimum model complexity
\node[OptimumStyle] at (axis cs:0.9,2) {Optimum Model\\Complexity};
\node[anchor=south west,text=Maroon] at (axis cs:1.4,0.4){Bias\textsuperscript{2}};
\node[anchor=north west,text=TealBlue] at (axis cs:1.4,0.85){Variance};
\node[anchor=south east,align=center] at (axis cs:1.5,1.5){Total\\error};
\legend{}
\end{axis}
\end{tikzpicture}
\end{document}