将图片嵌入矩阵

将图片嵌入矩阵

送出猫

答案1

我没有您的图形,也不会关注外部链接。因此,您需要example-image-duck用自己的文件名替换 s 列表。除此之外,它基本上与您使用的帖子相同。

\documentclass[tikz,border=3mm]{standalone}
\usepackage{fontawesome}
\usetikzlibrary{matrix,positioning,shapes.arrows}
\tikzset{marrow/.style={minimum height=1.4cm,minimum width=1.2cm,
   single arrow, single arrow
    head extend=.125cm, single arrow head indent=.08cm}}
\begin{document}
\begin{tikzpicture}[mymat/.style={matrix of nodes,column sep=-\pgflinewidth/2,row sep=-\pgflinewidth/2,
 nodes in empty cells,cells={nodes={draw,text depth=0.2ex,text height=1.75em,minimum
 width=1.9em,minimum height=1.9em,execute at begin node=\vphantom{1}}}},
 node font=\sffamily,>=stealth]
 % first matrix
 \matrix[mymat,column 1/.style={nodes={font=\Large}}] 
 (mat1) {
  |[text=blue]|\faUser & 5 & 3 & & & 3 \\
  |[text=green!70!black]|\faUser & & & 4 & &  \\
  |[text=purple]|\faUser & 4 & |[fill=blue!20,text=red]| ? & & 3 & 5  \\
  |[text=red]|\faUser & & & & &  \\
  |[text=orange]|\faUser & & & & &  \\
  |[text=black]|\faUser & & & & &  \\
 };
 % pics above first matrix (replace them by your own)
 \foreach \Pic [count=\Y starting from 2] in 
  {example-image-duck,example-image-duck,example-image-duck,example-image-duck,example-image-duck}
 {\node[above=0.1ex of mat1-1-\Y]{\includegraphics[width=1.8em]{\Pic}};} 
 % arrow
 \node[right=1ex of mat1,marrow,draw](marr){};
 % second matrix
 \matrix[mymat,right=1ex of marr,row 3/.style={
 nodes={/utils/exec={\unless\ifnum\the\pgfmatrixcurrentcolumn=1
 \tikzset{fill=blue!20}
 \fi}}},
 column 1/.style={nodes={font=\Large,draw=none}}] 
 (mat2) {
  |[text=blue]|\faUser &  &  &\\
  |[text=green!70!black]|\faUser & & &   \\
  |[text=purple]|\faUser & & &  \\
  |[text=red]|\faUser & & &   \\
  |[text=orange]|\faUser & & &   \\
  |[text=black]|\faUser & & &   \\
 };
 %
 \draw[cyan,<->] ([yshift=1ex]mat2.north-|mat2-1-2.west)  -- 
 ([yshift=1ex]mat2.north-|mat2-1-4.east) node[midway,above,black]{$k$};
 % third matrix
 \matrix[mymat,right=2.5em of mat2.north east,
 column 2/.style={nodes={fill=blue!20}}] 
 (mat3) {
  & & & & \\
  & & & & \\
  & & & & \\
 };
 %
 \draw[cyan,<->] ([xshift=-1ex]mat3.west|-mat3-3-1.south)  -- 
 ([xshift=-1ex]mat3.west|-mat3-1-1.north) node[midway,left,black]{$k$};
 % pics above third matrix (replace them by your own)
 \foreach \Pic [count=\Y] in 
  {example-image-duck,example-image-duck,example-image-duck,example-image-duck,example-image-duck}
 {\node[above=0.1ex of mat3-1-\Y]{\includegraphics[width=1.8em]{\Pic}};}  
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容