![如何绘制稀疏矩阵模式(是否使用 TikZ)?](https://linux22.com/image/468060/%E5%A6%82%E4%BD%95%E7%BB%98%E5%88%B6%E7%A8%80%E7%96%8F%E7%9F%A9%E9%98%B5%E6%A8%A1%E5%BC%8F%EF%BC%88%E6%98%AF%E5%90%A6%E4%BD%BF%E7%94%A8%20TikZ%EF%BC%89%EF%BC%9F.png)
答案1
我们将设置一个sparsity diagram
样式来设置适当的缩放比例坐标坐标系,绘制大矩形,并设置图表的基线,以便它们与操作员大致对齐。
然后我们只需绘制矩形并填充它们。
代码
\documentclass{article}
\usepackage{tikz}
\tikzset{
sparsity diagram/.style={
execute at begin picture={\draw(0,0)rectangle coordinate (midway) (3,3);},
x=+5mm, y=+5mm, baseline={([yshift=+-.5ex]midway)}}}
\begin{document}
\[
\tikz[sparsity diagram]{
\draw[fill=gray!50] (1,0) -| (3,2) -| coordinate (@1)
(2,3) -| (0,1) -| coordinate (@2) cycle;
\draw[dashed] (@1) rectangle (@2);
}
=
\tikz[sparsity diagram]
\draw[fill=gray!50] (0, 3) rectangle node {$H_{\beta_1}$} + (2,-2);
+
\tikz[sparsity diagram]
\draw[fill=gray!50] (1, 0) rectangle node {$H_{\beta_2}$}+ (2,2);
\]
\end{document}