[Tex/LaTex] Drawing this matrix using Tikz

matricestikz-matrixtikz-pgf

I have a matrix which has certain properties. To illustrate these properties, I would like to generate the following image using Tikz:

enter image description here

Additionally, I would like the following things on the image:

  1. The upper triangle should be shaded light blue
  2. The lower triangle should be shaded light red
  3. The red and blue lines should be dotted exactly where there are dots in the zeros along the horizontal and vertical directions.

I am new to using Tikz and any help with this would be greatly appreciated!

Best Answer

For fun: that is easy with pstricks:

\documentclass[11pt,x11names]{standalone}
\usepackage{pst-node}
\usepackage{auto-pst-pdf}
\usepackage{amsmath}
\usepackage{sansmath}

\begin{document}

 \mathversion{sans}\setlength\fboxsep{0pt}
\begin{postscript}
    $\begin{pmatrix}
        0 & 0 & 0 & 0 & \dots & 0 \\ 0 & \pnode[0,1.5ex]{A} & & &\pnode[0,1.5ex]{Dh} \\0\\0\\\vdots &\pnode{Dv} \\0 & & & & & \pnode{B}
    \end{pmatrix}$
    \psset{arrowinset=0, linewidth=1.5pt, linearc=0.2pt, nodesep = 6pt,, arrows =c- }
    \psline{<->}(A)(B)
    \psset{linecolor=RoyalBlue2, fillcolor=RoyalBlue1!15!, arrows =c-}
    \ncangle[angleB=90, linestyle = none, fillstyle=solid,]{A}{B}
    \ncline[nodesepB=9.5pt]{A}{Dh}
    \ncangle[angleA=90, nodesepB=7.5pt]{B}{Dh}
    \rput(Dh){\color{RoyalBlue2}\dots}
    \psset{angleA=-90, angleB=180, linecolor=Red1!60!, fillcolor=Red1!10!, arrows =-c}
    \ncangle[linestyle=none, fillstyle=solid]{A}{B}
    \ncangle[nodesepA=3pt,]{Dv}{B}
    \ncline[nodesepA=12pt]{Dv}{A}
    \rput[B](Dv){\color{Red1!60!}\vdots}
\end{postscript}

\end{document} 

enter image description here

Related Question