答案1
您可以使用groupplots
库来pgfplots
形成子图网格。然后,您可以使用选项area style
填充图形下方的区域并const plot
更轻松地绘制锯齿线。
\documentclass{beamer}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\usepackage[tightpage,active]{preview}
\PreviewEnvironment{tikzpicture}
\begin{document}
\begin{tikzpicture}
\begin{groupplot} [
group style={group size = 2 by 2,},
area style,
hide axis,
enlarge x limits=false,
xmax=5,xmin=0,ymax=5,ymin=0,
]
\nextgroupplot[const plot,]
\addplot[mark=none,draw=black,fill=green!64!blue] coordinates {
(0,5) (4,5)
} \closedcycle
;
\addplot[mark=none,draw=black,fill=magenta] coordinates {
(4,5) (5,5)
} \closedcycle;
\addplot[mark=none] coordinates {(3,3)}
node[pos=0] {$A$};
\addplot[mark=none] coordinates {(4.5,3)}
node[pos=0] {$b$};
\nextgroupplot[const plot,]
\addplot[mark=none,draw=black,fill=green!64!blue] coordinates {
(0,5) (4,5)
} \closedcycle
;
\addplot[mark=none,draw=black,fill=magenta] coordinates {
(4,5) (5,5)
} \closedcycle;
\addplot[mark=none,draw=black,fill=white] coordinates {
(0,4) (1,4)
} \closedcycle;
\addplot[mark=none] coordinates {(3,3)}
node[pos=0] {$A^{(1)}$};
\addplot[mark=none] coordinates {(4.5,3)}
node[pos=0] {$b^{(1)}$};
\nextgroupplot[const plot,]
\addplot[mark=none,draw=black,fill=green!64!blue] coordinates {
(0,5) (4,5)
} \closedcycle
;
\addplot[mark=none,draw=black,fill=magenta] coordinates {
(4,5) (5,5)
} \closedcycle;
\addplot[mark=none,draw=black,fill=white] coordinates {
(0,4) (1,3) (2,3)
} \closedcycle;
\addplot[mark=none] coordinates {(3.5,3)}
node[pos=0] {$A^{(2)}$};
\addplot[mark=none] coordinates {(4.5,3)}
node[pos=0] {$b^{(2)}$};
\nextgroupplot[const plot,]
\addplot[mark=none,draw=black,fill=green!64!blue] coordinates {
(0,5) (4,5)
} \closedcycle
;
\addplot[mark=none,draw=black,fill=magenta] coordinates {
(4,5) (5,5)
} \closedcycle;
\addplot[mark=none,draw=black,fill=white] coordinates {
(0,4) (1,3) (2,3) (2,2) (3,2)
} \closedcycle;
\addplot[mark=none] coordinates {(3.5,3)}
node[pos=0] {$A^{(3)}$};
\addplot[mark=none] coordinates {(4.5,3)}
node[pos=0] {$b^{(3)}$};
\end{groupplot}
\end{tikzpicture}
\end{document}