我正在尝试重新创建以下图形:
我知道这个问题以前有人问过这里但解决方案需要使用 进行编译lualatex
。
我目前有以下几点:
Low Variance
我正在尝试通过添加、High Variance
和标题/轴Low Bias
来完成图形。High Bias
我也尝试增加地块之间的空间subfigure
。垂直空间似乎不错,但水平空间太近了。
最后:
我想在该图中添加两个附加标签(overfitting
和underfitting
),如下图所示。
(另外:如果我可以在点周围添加黑色边框,那就太好了,如果我可以像第一个图那样使颜色变深,那就太好了。我尝试了几种方法让颜色变深,但没有成功)
代码:
\documentclass{article}
\usepackage{tikz}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}{0.45\textwidth}
\begin{tikzpicture}
\foreach \r/\col in {2.8 cm/white,2 cm/blue!50!white,1.2 cm/white,0.4 cm/red!50!white}{%
\path[draw,fill=\col] (0,0) circle (\r) ;}
\foreach \coords in {(0,.1),(.1,.1),(.1,.2),(-.1,0),(-.2,.1),(-.1,-.1),(-.2,-.3),(-.3,-.1),(.3,-.1),(0,-.1),(-.1,0),(-.2,-.1),(-.2,-.2)}{%
\draw[fill=blue] \coords circle (.6mm);}
\end{tikzpicture}
\end{subfigure}
\hfill
\begin{subfigure}{0.45\textwidth}
\begin{tikzpicture}
\foreach \r/\col in {2.8 cm/white,2 cm/blue!50!white,1.2 cm/white,0.4 cm/red!50!white}{%
\path[draw,fill=\col] (0,0) circle (\r) ;}
\foreach \coords in {(0,.8),(.2,.9),(.8,.1),(-.1,.7),(-.1,-.4),(-.3,-.1),(-.4,-.9),(.2,-.9),(.5,.5),(-.5,.8),(-.7,-.8),(-.2,-.3),(-.5,0)}{%
\draw[fill=blue] \coords circle (.6mm);}
\end{tikzpicture}
\end{subfigure}
\bigskip
\begin{subfigure}{0.45\textwidth}
\begin{tikzpicture}
\foreach \r/\col in {2.8 cm/white,2 cm/blue!50!white,1.2 cm/white,0.4 cm/red!50!white}{%
\path[draw,fill=\col] (0,0) circle (\r) ;}
\foreach \coords in {(0,1.2),(.1,1.4),(-.1,1.3),(-.2,1.2),(-.1,1.3),(-.1,1.4),(-.2,1.5),(0,1.3),(.3,1.4),(0,1.6),(.1,1.6),(-.2,1.5),(.2,1.7)}{%
\draw[fill=blue] \coords circle (.6mm);}
\end{tikzpicture}
\end{subfigure}
\hfill
\begin{subfigure}{0.45\textwidth}
\begin{tikzpicture}
\foreach \r/\col in {2.8 cm/white,2 cm/blue!50!white,1.2 cm/white,0.4 cm/red!50!white}{%
\path[draw,fill=\col] (0,0) circle (\r) ;}
\foreach \coords in {(0,1.3),(-1.3,0.4),(-1.4,2.0),(-1.2,1.0),(-1.0,1.6),(-.5,1.7),(-.2,1.5),(-.9,1.9),(.1,1.7),(-.9,1.6),(-.3,1.8),(-.6,1.7),(-.9,1.9)}{%
\draw[fill=blue] \coords circle (.6mm);}
\end{tikzpicture}
\end{subfigure}
\caption{}
\label{fig:biasVarianceTradeOff}
\end{figure}
\end{document}
答案1
无需对您的方法进行太多改变的可能解决方案:
梅威瑟:
\documentclass{article}
\usepackage{tikz}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}{0.40\textwidth}
\begin{tikzpicture}
\foreach \r/\col in {2.8 cm/white,2 cm/blue,1.2 cm/white,0.4 cm/red}{%
\path[draw,fill=\col] (0,0) circle (\r) node[align=center,above,text height=1cm,yshift=3cm]{Low\\Variance} node[align=center,left,text width=1cm,xshift=-3cm]{Low\\Bias};}
\foreach \coords in {(0,.1),(.1,.1),(.1,.2),(-.1,0),(-.2,.1),(-.1,-.1),(-.2,-.3),(-.3,-.1),(.3,-.1),(0,-.1),(-.1,0),(-.2,-.1),(-.2,-.2)}{%
\draw[fill=green] \coords circle (.6mm);}
\end{tikzpicture}
\end{subfigure}
\hfill
\begin{subfigure}{0.40\textwidth}
\begin{tikzpicture}
\foreach \r/\col in {2.8 cm/white,2 cm/blue,1.2 cm/white,0.4 cm/red}{%
\path[draw,fill=\col] (0,0) circle (\r) node[align=center,above,text height=1cm,yshift=3cm]{High\\Variance};}
\foreach \coords in {(0,.8),(.2,.9),(.8,.1),(-.1,.7),(-.1,-.4),(-.3,-.1),(-.4,-.9),(.2,-.9),(.5,.5),(-.5,.8),(-.7,-.8),(-.2,-.3),(-.5,0)}{%
\draw[fill=green] \coords circle (.6mm);}
\node[red] (uf1) at (2.5,-2.5) {Overfitting};
\coordinate (uf2) at (.5,-0.7);
\draw [-latex,red,line width= 1.5pt] (uf1) -- (uf2);
\end{tikzpicture}
\end{subfigure}
\par\bigskip
\begin{subfigure}{0.40\textwidth}
\begin{tikzpicture}
\foreach \r/\col in {2.8 cm/white,2 cm/blue,1.2 cm/white,0.4 cm/red}{%
\path[draw,fill=\col] (0,0) circle (\r) node[align=center,left,text width=1cm,xshift=-3cm]{High\\Bias};}
\foreach \coords in {(0,1.2),(.1,1.4),(-.1,1.3),(-.2,1.2),(-.1,1.3),(-.1,1.4),(-.2,1.5),(0,1.3),(.3,1.4),(0,1.6),(.1,1.6),(-.2,1.5),(.2,1.7)}{%
\draw[fill=green] \coords circle (.6mm);}
\node[red] (uf1) at (-2.5,2.5) {Underfitting};
\coordinate (uf2) at (-.25,1.5);
\draw [-latex,red,line width= 1.5pt] (uf1) -- (uf2);
\node[red] (tr1) at (-2.5,-2.5) {Truth};
\coordinate (tr2) at (-0.3,-0.3);
\draw [-latex,red,line width= 1.5pt] (tr1) -- (tr2);
\end{tikzpicture}
\end{subfigure}
\hfill
\begin{subfigure}{0.40\textwidth}
\begin{tikzpicture}
\foreach \r/\col in {2.8 cm/white,2 cm/blue,1.2 cm/white,0.4 cm/red}{%
\path[draw,fill=\col] (0,0) circle (\r) ;}
\foreach \coords in {(0,1.3),(-1.3,0.4),(-1.4,2.0),(-1.2,1.0),(-1.0,1.6),(-.5,1.7),(-.2,1.5),(-.9,1.9),(.1,1.7),(-.9,1.6),(-.3,1.8),(-.6,1.7),(-.9,1.9)}{%
\draw[fill=green] \coords circle (.6mm);}
\end{tikzpicture}
\end{subfigure}
\caption{Graphical illustration of bias and variance}
\label{fig:biasVarianceTradeOff}
\end{figure}
\end{document}