我需要绘制这两个图:
我不想使用这些图像,而是想使用包\usepackage{fontawesome}
,这样我就可以按照这里所述选择多个图标fontawesome 包。
MWE(致谢薛定谔的猫)
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
chains,
positioning}
\usepackage{fontawesome}
\usepackage{tikzpeople}
\begin{document}
\begin{tikzpicture}[node distance = 8mm and 44mm,
start chain = A going below,
oh no/.style = {inner sep=0pt, rounded corners,scale=pi,
on chain=A},
>={Straight Barb[angle=60:2pt 3]},
arr/.style = {color=#1, ultra thick,->}
]
\node[oh no,alice] {}; % A-1
\node[oh no,alice] {};
\node[oh no,bob] {};% A-3
%
\node[oh no,above right=of A-1.east,label=below:4]{\faFileTextO}; % A-4
\node[oh no,label=below:4] {\faFileTextO};
\node[oh no,label=below:4] {\faFileTextO};
\node[oh no,label=below:4] {\faFileTextO}; % A-7
%
\draw[red, ultra thick,<->] (A-4.east) to [bend left=45] (A-6.east);
\foreach \i in {4,6,7}
{\draw[arr=black] (A-1.east) -- (A-\i);}
\draw[arr=blue!50!gray] (A-2.east) -- (A-4);
\draw[arr=blue!50!gray] (A-2.east) -- (A-6);
\foreach \i in {6}
{\draw[arr=purple!50!gray] (A-3.east) -- (A-\i);}
%
\draw[arr=orange,densely dashed] (A-4) -- (A-3);
%\draw[arr=brown,densely dashed] (A-7) -- (A-3);
\draw[arr=orange, ultra thick,dashed,->] (A-7) to [bend left=45] (A-3);
\end{tikzpicture}
\end{document}
答案1
为此,我建议使用matrix
。您必须用自己想要的任何符号替换这些符号。
\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikzpeople}
\usepackage{fontawesome}
\usetikzlibrary{matrix,positioning}
\begin{document}
\begin{tikzpicture}[font=\sffamily]
\node[alice,label=above:User A,scale=2](alice){};
\matrix[matrix of nodes,right=3em of alice,row sep=1em,
column 1/.style={column sep=3em},column 4/.style={column sep=3em},
cells={nodes={font=\Huge}},
column 6/.style={nodes={font=\normalsize\sffamily,yshift=1em}}] (mat) {
\faLinux & \faOptinMonster & \faSuitcase & \faUserSecret & \faUser & 1 \\
\faLinux & \faOptinMonster & \faSuitcase & \faUserSecret & \faUser & 2 \\
\faLinux & \faOptinMonster & \faSuitcase & \faUserSecret & \faUser & 3 \\
\faLinux & \faOptinMonster & \faSuitcase & \faUserSecret & \faUser & 4 \\
};
\foreach \X in {1,...,4}
{\draw[very thick,green!60!black] (alice) -- (mat-\X-1) (mat-\X-1) -- (mat-\X-2);}
\path[nodes={align=center}]
(mat.north-|mat-1-1) node[above] {Similars of\\ User A}
(mat.north-|mat-1-2.west) -- (mat.north-|mat-1-4.east)
node[midway,above] {Items of\\ \dots}
(mat.north-|mat-1-5.west) -- (mat.north-|mat-1-6.east)
node[midway,above] {Counts \& Rank} ;
\draw[line width=1mm,-latex] (mat.center-|mat-1-4.east) --
(mat.center-|mat-1-5.west);
\end{tikzpicture}
\end{document}
或者带有标签。
\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikzpeople}
\usepackage{fontawesome}
\usetikzlibrary{matrix,positioning}
\begin{document}
\begin{tikzpicture}[node font=\sffamily]
\node[alice,label=above:User A,scale=2](alice){};
\matrix[matrix of nodes,right=3em of alice,row sep=1em,
column 1/.style={column sep=3em},column 4/.style={column sep=3em},
cells={nodes={font=\Huge}},cells={every label/.style={font=\normalsize}},
column 6/.style={nodes={font=\normalsize\sffamily,yshift=1em}}] (mat) {
|[label=below:1]|\faLinux & \faOptinMonster & \faSuitcase & \faUserSecret & \faUser & 1 \\
|[label=below:2]|\faLinux & \faOptinMonster & \faSuitcase & \faUserSecret & \faUser & 2 \\
|[label=below:3]|\faLinux & \faOptinMonster & \faSuitcase & \faUserSecret & \faUser & 3 \\
|[label=below:4]|\faLinux & \faOptinMonster & \faSuitcase & \faUserSecret & \faUser & 4 \\
};
\foreach \X in {1,...,4}
{\draw[very thick,green!60!black] (alice) -- (mat-\X-1) (mat-\X-1) -- (mat-\X-2);}
\path[nodes={align=center}]
(mat.north-|mat-1-1) node[above] {Similars of\\ User A}
(mat.north-|mat-1-2.west) -- (mat.north-|mat-1-4.east)
node[midway,above] {Items of\\ \dots}
(mat.north-|mat-1-5.west) -- (mat.north-|mat-1-6.east)
node[midway,above] {Counts \& Rank} ;
\draw[line width=1mm,-latex] (mat.center-|mat-1-4.east) --
(mat.center-|mat-1-5.west);
\end{tikzpicture}
\end{document}