绘制一个分为上、下和对角线部分的矩阵

绘制一个分为上、下和对角线部分的矩阵

你能告诉我如何绘制这个分为上、下和对角线部分的矩阵图像,并注释外部括号和矩阵元素吗?

在此处输入图片描述

\documentclass[10pt]{article}
\usepackage{pgf,tikz}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
\definecolor{zzttqq}{rgb}{0.6,0.2,0.}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\clip(-3.5056858353566276,-0.9242940428141289) rectangle (4.030674445189699,6.7420034839485234);
\fill[line width=0.8pt,color=zzttqq,fill=zzttqq,fill opacity=0.10000000149011612] (-3.,5.) -- (-3.,4.) -- (-2.,4.) -- (-2.,5.) -- cycle;
\fill[line width=0.8pt,color=zzttqq,fill=zzttqq,fill opacity=0.10000000149011612] (-3.,4.) -- (-3.,3.) -- (-1.,3.) -- (-1.,4.) -- cycle;
\fill[line width=0.8pt,color=zzttqq,fill=zzttqq,fill opacity=0.10000000149011612] (-3.,3.) -- (-3.,2.) -- (0.,2.) -- (0.,3.) -- cycle;
\fill[line width=0.8pt,color=zzttqq,fill=zzttqq,fill opacity=0.10000000149011612] (-3.,2.) -- (-3.,1.) -- (1.,1.) -- (1.,2.) -- cycle;
\fill[line width=0.8pt,color=zzttqq,fill=zzttqq,fill opacity=0.10000000149011612] (-2.,6.) -- (-2.,5.) -- (-1.,5.) -- (-1.,6.) -- cycle;
\fill[line width=0.8pt,color=zzttqq,fill=zzttqq,fill opacity=0.10000000149011612] (-1.,6.) -- (-1.,4.) -- (0.,4.) -- (0.,6.) -- cycle;
\fill[line width=0.8pt,color=zzttqq,fill=zzttqq,fill opacity=0.10000000149011612] (0.,4.) -- (0.,3.) -- (1.,3.) -- (1.,6.) -- (0.,6.) -- cycle;
\fill[line width=0.8pt,color=zzttqq,fill=zzttqq,fill opacity=0.10000000149011612] (1.,2.) -- (2.,2.) -- (2.,6.) -- (1.,6.) -- cycle;
\draw [line width=0.8pt] (-3.,6.)-- (-3.,5.);
\draw [line width=0.8pt] (-2.,5.)-- (-2.,6.);
\draw [line width=0.8pt] (-2.,6.)-- (-3.,6.);
\draw [line width=0.8pt] (-3.,5.)-- (-2.,5.);
\draw [line width=0.8pt] (-2.,5.)-- (-2.,4.);
\draw [line width=0.8pt] (-2.,4.)-- (-1.,4.);
\draw [line width=0.8pt] (-1.,4.)-- (-1.,5.);
\draw [line width=0.8pt] (-1.,5.)-- (-2.,5.);
\draw [line width=0.8pt] (-1.,4.)-- (-1.,3.);
\draw [line width=0.8pt] (-1.,3.)-- (0.,3.);
\draw [line width=0.8pt] (0.,3.)-- (0.,4.);
\draw [line width=0.8pt] (0.,4.)-- (-1.,4.);
\draw [line width=0.8pt] (0.,3.)-- (0.,2.);
\draw [line width=0.8pt] (0.,2.)-- (1.,2.);
\draw [line width=0.8pt] (1.,2.)-- (1.,3.);
\draw [line width=0.8pt] (1.,3.)-- (0.,3.);
\draw [line width=0.8pt] (1.,2.)-- (1.,1.);
\draw [line width=0.8pt] (1.,1.)-- (2.,1.);
\draw [line width=0.8pt] (2.,1.)-- (2.,2.);
\draw [line width=0.8pt] (2.,2.)-- (1.,2.);
\draw [line width=0.8pt] (2.,1.)-- (2.,0.);
\draw [line width=0.8pt] (2.,0.)-- (3.,0.);
\draw [line width=0.8pt] (3.,0.)-- (3.,1.);
\draw [line width=0.8pt] (3.,1.)-- (2.,1.);
\draw [line width=0.8pt,color=zzttqq] (-3.,5.)-- (-3.,4.);
\draw [line width=0.8pt,color=zzttqq] (-3.,4.)-- (-2.,4.);
\draw [line width=0.8pt,color=zzttqq] (-2.,4.)-- (-2.,5.);
\draw [line width=0.8pt,color=zzttqq] (-2.,5.)-- (-3.,5.);
\draw [line width=0.8pt,color=zzttqq] (-3.,4.)-- (-3.,3.);
\draw [line width=0.8pt,color=zzttqq] (-3.,3.)-- (-1.,3.);
\draw [line width=0.8pt,color=zzttqq] (-1.,3.)-- (-1.,4.);
\draw [line width=0.8pt,color=zzttqq] (-1.,4.)-- (-3.,4.);
\draw [line width=0.8pt,color=zzttqq] (-3.,3.)-- (-3.,2.);
\draw [line width=0.8pt,color=zzttqq] (-3.,2.)-- (0.,2.);
\draw [line width=0.8pt,color=zzttqq] (0.,2.)-- (0.,3.);
\draw [line width=0.8pt,color=zzttqq] (0.,3.)-- (-3.,3.);
\draw [line width=0.8pt,color=zzttqq] (-3.,2.)-- (-3.,1.);
\draw [line width=0.8pt,color=zzttqq] (-3.,1.)-- (1.,1.);
\draw [line width=0.8pt,color=zzttqq] (1.,1.)-- (1.,2.);
\draw [line width=0.8pt,color=zzttqq] (1.,2.)-- (-3.,2.);
\draw [line width=0.8pt,color=zzttqq] (-2.,6.)-- (-2.,5.);
\draw [line width=0.8pt,color=zzttqq] (-2.,5.)-- (-1.,5.);
\draw [line width=0.8pt,color=zzttqq] (-1.,5.)-- (-1.,6.);
\draw [line width=0.8pt,color=zzttqq] (-1.,6.)-- (-2.,6.);
\draw [line width=0.8pt,color=zzttqq] (-1.,6.)-- (-1.,4.);
\draw [line width=0.8pt,color=zzttqq] (-1.,4.)-- (0.,4.);
\draw [line width=0.8pt,color=zzttqq] (0.,4.)-- (0.,6.);
\draw [line width=0.8pt,color=zzttqq] (0.,6.)-- (-1.,6.);
\draw [line width=0.8pt,color=zzttqq] (0.,4.)-- (0.,3.);
\draw [line width=0.8pt,color=zzttqq] (0.,3.)-- (1.,3.);
\draw [line width=0.8pt,color=zzttqq] (1.,3.)-- (1.,6.);
\draw [line width=0.8pt,color=zzttqq] (1.,6.)-- (0.,6.);
\draw [line width=0.8pt,color=zzttqq] (0.,6.)-- (0.,4.);
\draw [line width=0.8pt,color=zzttqq] (1.,2.)-- (2.,2.);
\draw [line width=0.8pt,color=zzttqq] (2.,2.)-- (2.,6.);
\draw [line width=0.8pt,color=zzttqq] (2.,6.)-- (1.,6.);
\draw [line width=0.8pt,color=zzttqq] (1.,6.)-- (1.,2.);
\draw [line width=0.8pt] (-3.,1.)-- (-3.,0.);
\draw [line width=0.8pt] (-3.,0.)-- (2.,0.);
\draw [line width=0.8pt] (2.,0.)-- (2.,1.);
\draw [line width=0.8pt] (2.,1.)-- (-3.,1.);
\draw [line width=0.8pt] (2.,6.)-- (2.,1.);
\draw [line width=0.8pt] (2.,1.)-- (3.,1.);
\draw [line width=0.8pt] (3.,1.)-- (3.,6.);
\draw [line width=0.8pt] (3.,6.)-- (2.,6.);
\end{tikzpicture}
\end{document}

答案1

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,patterns,arrows.meta,decorations.pathreplacing}

\tikzset{diag/.style={draw,minimum width=.95cm,minimum height=.95cm},
        upper/.style={draw,minimum width=.95cm,pattern=north east lines},
        lower/.style={draw,minimum height=.95cm,pattern=north west lines}
}


\begin{document}

\begin{tikzpicture}[node distance=.025cm+\pgflinewidth]


\foreach \cord/\Name in {{(-2,2)}/A,{(-1,1)}/B,{(0,0)}/C,{(1,-1)}/D,{(2,-2)}/E,{(3,-3)}/F}
{\node[diag](\Name) at \cord{};}

\node[above=of B,upper,minimum height=0.95cm] (U1){};
\node[above=of C,upper,minimum height=1.95cm] (U2){};
\node[above=of D,upper,minimum height=2.95cm] (U3){};
\node[above=of E,upper,minimum height=3.95cm] (U4){};
\node[above=of F,upper,minimum height=4.95cm,pattern=none] (U5){};

\node[left=of B,lower,minimum width=0.95cm] (L1){};
\node[left=of C,lower,minimum width=1.95cm] (L2){};
\node[left=of D,lower,minimum width=2.95cm] (L3){};
\node[left=of E,lower,minimum width=3.95cm] (L4){};
\node[left=of F,lower,minimum width=4.95cm,pattern=none] (L5){};

\draw[-{Triangle},transform canvas={yshift=2mm}](U1.north west)--(U4.north east);
\draw[decorate,decoration={brace,amplitude=8pt,raise=3mm}](U1.north west)--(U4.north east)node[midway,yshift=8mm]{U part};

\draw[-{Triangle},transform canvas={xshift=-2mm}](L1.north west)--(L4.south west);
\draw[decorate,decoration={brace,amplitude=8pt,mirror,raise=3mm}](L1.north west)--(L4.south west)node[midway,xshift=-12mm]{L part};

\draw[-{Triangle}]([shift={(-2mm,2mm)}]A.north west)node[anchor=south east]{D part}--(E.south east);


\draw[-{Triangle}]([yshift=2mm]U5.south)--([yshift=2mm]U5.north)--+(1cm,0)node[anchor=west]{$U_{i,1:i-1}$};

\draw[-{Triangle}]([xshift=-2mm]L5.east)--([xshift=-2mm]L5.west)--+(0,-1cm)node[anchor=north]{$L_{i,1:i-1}$};

\draw[-{Triangle}](F.center)--+(1cm,-1cm)node[anchor=north west]{$D_H$};

\end{tikzpicture}

\end{document}

在此处输入图片描述

答案2

在前面添加这些行\end{tikzpicture}并添加\usetikzlibrary{decorations.pathreplacing}序言。

\draw [decorate,decoration={brace,amplitude=5pt,raise=5pt},thick] (-3,1) -- (-3,5);
\draw [decorate,decoration={brace,amplitude=5pt,raise=5pt},thick] (-2,6) -- (2,6);
\end{tikzpicture}

结果是

在此处输入图片描述

相关内容