5

I have the following matrices with its respective code. The attached image shows the output. Since I have to put that image into an academic thesis, I thought that my actual design is a little bit over the line, in terms of style, meaning, I need to make it look more "mathematical".

\documentclass{standalone}
%\usepackage[showframe]{geometry}
\usepackage{tikz}
\definecolor{gris}{RGB}{250,250,250}
\usepackage{lmodern}
\usetikzlibrary{matrix,
    positioning}
\tikzset{
    mymatrix/.style = {matrix of nodes,
        nodes in empty cells,
        nodes={minimum height=3ex, minimum width=1em,
            inner sep=0pt, outer sep=0pt, anchor=center,
            draw, very thin,scale=0.8,transform shape},
        column sep=0pt,
        row sep=0pt,
        inner sep=0.5\pgflinewidth, outer sep=1pt,
        draw, thick},
    empty node/.style = {draw,fill=gris},
    every label/.append style = {font=\large, text=teal}
}
\makeatletter
\def\tikz@lib@matrix@empty@cell{%
    \iftikz@lib@matrix@empty%
    \node[name=\tikzmatrixname-\the\pgfmatrixcurrentrow-\the\pgfmatrixcurrentcolumn,empty node]{};\fi}
\makeatother

\usepackage{bm}
\newcommand{\MatrixVariable}[1]{\bm{{#1}}}

\begin{document}

    \begin{tikzpicture}[node distance=0pt,scale=0.6,nodes={transform
        shape}]
    \matrix (m1) [mymatrix,
    label={[rotate=90, anchor=south,black]left: Movies},
    label={[black]below:$\MatrixVariable{{R}}$},
    label={[black]above:Users},
    nodes={fill=gray!30}]
    {
        1   &   & 3 &   &   & 5 &   &   & 5 &   & 4 &   \\
        &   & 5 & 4 &   &   & 4 &   &   & 2 & 1 & 3 \\
        2   & 4 &   & 1 & 2 &   & 3 &   & 4 & 3 & 5 &   \\
        & 2 & 4 &   & 5 &   &   & 4 &   &   & 2 &   \\
        &   & 4 & 3 & 4 & 2 &   &   &   &   & 2 & 5 \\
        1   &   & 3 &   & 3 &   &   & 2 &   &   & 4 &   \\
    };
    \node (approx) [right=of m1,scale=2] {$\approx$};
    \matrix (m2) [mymatrix=none, right=0.1em of approx,
    label={[rotate=90, anchor=south east,xshift=-0.7em,black]left: Movies},
    label={[black]below:$\MatrixVariable{{Q}}$},
    label={[black]above:$f$-factors},
    nodes={minimum width=2.2em,fill=white}]
    {
        0.1& -0.4  & -0.2 \\
        -0.5& 0.6 & 0.5 \\
        -0.2& 0.3 &0.5  \\
        1.1& 2.1 & 0.3 \\
        -0.7&2.1  & -2 \\
        -1& 0.7 & 0.3 \\
    };
    \node (times) [right=of m2,scale=2] {$\cdot$};
    \matrix (m3) [mymatrix=none, right=of times,
    label={[rotate=90, anchor=north,black]right: $f$-factors},
    label={[black]below:$\MatrixVariable{{P}^{T}}$},
    label={[black]above:Users},
    nodes={minimum width=2em,fill=white}]
    {
        1.1&-2  & 0.3 & 0.5 &-2  &  -0.5 & 0.8 & -0.4 & 0.3 & 1.4 & 2.4 &  -0.9\\
        -0.8& 0.7 & 0.5 & 1.4 &0.3  & -1 & 1.4 & 2.9 & 0.7 & - 1.2 & 1.3& 0.4\\
        2.1& -0.4 & 0.6 & 1.7 & 2.4 & 0.9 & -0.3 & 0.4 &  0.8 &   0.7 & -0.6&0.1 \\
    };
    \end{tikzpicture}

\end{document}

enter image description here

This is what I've got in mind:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
    \[
    \begin{pmatrix}
    x_{11}       & x_{12} & x_{13} & \dots & x_{1n} \\
    x_{21}       & x_{22} & x_{23} & \dots & x_{2n} \\
    \hdotsfor{5} \\
    x_{d1}       & x_{d2} & x_{d3} & \dots & x_{dn}
    \end{pmatrix}
    =
    \begin{pmatrix}
    x_{11} & x_{12} & x_{13} & \dots  & x_{1n} \\
    x_{21} & x_{22} & x_{23} & \dots  & x_{2n} \\
    \vdots & \vdots & \vdots & \ddots & \vdots \\
    x_{d1} & x_{d2} & x_{d3} & \dots  & x_{dn}
    \end{pmatrix}
    \]
\end{document}

enter image description here

I am having some trouble with the labels Movies, Users and factors. Could you give me a hand on this one?

ps: I also thought about this one, but it would be great to add more k factors:

enter image description here

  • 1
    What is the (LaTeX) problem? Now your question seems to be opinion based, so will suggest to close it as such. – Zarko Aug 6 '19 at 7:10
  • I see nothing “not academic”, except that the rule for passing from the right-hand side to the left-hand side is not really clear, nor is the meaning of ≈. – egreg Aug 6 '19 at 10:28
  • @egreg This is not very academic. Do you see a duck? ;-) – user121799 Aug 6 '19 at 18:25
6

Using array and rotatebox

enter image description here

MWE

\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}
\begin{document}
\[\begin{array}{ccc}
 \text{Users} & &  \text{factors}\\
    \rotatebox[origin=c]{90}{\text{Movies}}
    \begin{pmatrix}
    x_{11}       & x_{12} & x_{13} & \dots & x_{1n} \\
    x_{21}       & x_{22} & x_{23} & \dots & x_{2n} \\
    \hdotsfor{5} \\
    x_{d1}       & x_{d2} & x_{d3} & \dots & x_{dn}
    \end{pmatrix}
    &=&
    \rotatebox[origin=c]{90}{\text{Movies}}
    \begin{pmatrix}
    x_{11} & x_{12} & x_{13} & \dots  & x_{1n} \\
    x_{21} & x_{22} & x_{23} & \dots  & x_{2n} \\
    \vdots & \vdots & \vdots & \ddots & \vdots \\
    x_{d1} & x_{d2} & x_{d3} & \dots  & x_{dn}
    \end{pmatrix}
\end{array}\]
\end{document}
2

Maybe you liked:

enter image description here

\documentclass{article}
\usepackage{amsmath}
\begin{document}
    \[
    \underbrace{\!
    \begin{pmatrix}
    x_{11} & x_{12} & \dots  & x_{1n} \\
    x_{21} & x_{22} & \dots  & x_{2n} \\
    \vdots & \vdots & \ddots & \vdots \\
    x_{d1} & x_{d2} & \dots  & x_{dn}
    \end{pmatrix}\!
    }_{\mathbf{R}_{\text{Movies}\times \text{Users}}}
    \approx
    \underbrace{\!
    \begin{pmatrix}
    y_{11} & y_{12} & \dots  & y_{1n} \\
    y_{21} & y_{22} & \dots  & y_{2n} \\
    \vdots & \vdots & \ddots & \vdots \\
    y_{d1} & y_{d2} & \dots  & y_{dn}
    \end{pmatrix}\!
    }_{\mathbf{Q}_{\text{Movies}\times f\text{-factors}}}
    \cdot
    \underbrace{
    \begin{pmatrix}\!
    z_{11} & z_{12} & \dots  & z_{1n} \\
    z_{21} & z_{22} & \dots  & z_{2n} \\
    \vdots & \vdots & \ddots & \vdots \\
    z_{d1} & z_{d2} & \dots  & z_{dn}
    \end{pmatrix}\!
    }_{\mathbf{P}^T_{f\text{-factors}\times\text{Users}}}
    \]
\end{document}
  • 3
    How is it possible that you first answer a question and then vote to close it as opinion based? To an outsider it seems like a reaction to not getting the tick. – user121799 Aug 6 '19 at 13:11
  • @user121799, because after my answer OP change the question and actually with changes ask for opinion. I explained this in my comment below question. – Zarko Aug 6 '19 at 13:31
  • 1
    Well, if that's the case, i.e. if this is not an answer to the question, wouldn't it be better to delete it? – user121799 Aug 6 '19 at 14:30
  • @marmot, It was answer to original question. At least I thing so. – Zarko Aug 6 '19 at 14:33
  • Hmmmh, you also initiated the closure of this one after some other answer got the tick.... – user121799 Aug 6 '19 at 14:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.