我的问题与下列答案为了绘制非常基本的(草图)人物。我在时间线上对齐和缩放基本人物时遇到了麻烦。以下代码片段绘制了稍大一些的人物图形。
\usepackage{tikz} \begin{document} \begin{tikzpicture} \draw[fill=black] (0,0) circle [radius=18pt] node[yshift=10mm] {Alice}; \draw[thick,fill=black] (1,-1.8) arc(0:180:1cm and 1 cm); \end{tikzpicture} \end{document} ```
例子:
\documentclass[tikz, margin=3mm]{standalone}
\usepackage{siunitx}
\usepackage{tikzpeople}
\usetikzlibrary{positioning,calc, arrows.meta}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}
\draw[->, -Latex, line width=1pt] (0,0)node(a){} -- (11,0) node (b)[below] {} ;
\foreach \x [count=\i] in {0,50,...,500}
{
\def \inBetSpace {1}
\draw[line width=1pt] (\i*\inBetSpace-\inBetSpace,-2mm) node[below](n\i) {\x} -- ++(0,4mm);
}
\node[bob,minimum size=0.8cm, label=\scriptsize Bob] (ail) at (2,2.4) {};
\draw[->, -Latex, line width=1pt] (ail) -- +(0,-2.4+0.2)node[fill=white, anchor=center, double=black,
midway,inner sep=1pt](a){\tiny Submits};
\node[bob,minimum size=0.8cm, label=\scriptsize Alice] (ail) at (5,2.4) {};
\draw[->, -Latex, line width=1pt] (ail) -- +(0,-2.4+0.2)node[fill=white, anchor=center, double=black,
midway,inner sep=1pt](a){\tiny Submits};
\end{tikzpicture}
\end{document}
输出:
我只是想用基本人物形象来Alice
替代。Bob
- 我无法使其对齐和缩放。
- 我无法将箭头链接到所绘制的人物形象上。
有没有什么简单的方法可以绘制以下草图?
答案1
一条建议:
\documentclass[tikz, margin=3mm]{standalone}
\usepackage{siunitx}
\usepackage{tikzpeople}
\usetikzlibrary{positioning,calc, arrows.meta}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}
\draw[->, -Latex, line width=1pt] (0,0)node(a){} -- (11,0) node (b)[below] {} ;
\foreach \x [count=\i] in {0,50,...,500}
{
\def \inBetSpace {1}
\draw[line width=1pt] (\i*\inBetSpace-\inBetSpace,-2mm) node[below](n\i) {\x} -- ++(0,4mm);
}
% Bob
\draw[thick,fill=black] (2.4,2.2) arc(0:180:0.4cm and 0.4 cm) node[below,midway](ail){Bob};
\node[above=of ail,circle,fill=black,yshift=-0.9cm,minimum size=0.5cm,label=above:{\scriptsize Bob}]{};
\draw[->, -Latex, line width=1pt] (ail) -- +(0,-2.2+0.2)node[fill=white, anchor=center, double=black,
midway,inner sep=1pt](a){\tiny Submits};
% Alice
\draw[thick,fill=black] (5.4,2.2) arc(0:180:0.4cm and 0.4 cm) node[below,midway](ail){alice};
\node[above=of ail,circle,fill=black,yshift=-0.9cm,minimum size=0.5cm,label=above:{\scriptsize Alice}]{};
\draw[->, -Latex, line width=1pt] (ail) -- +(0,-2.2+0.2)node[fill=white, anchor=center, double=black,
midway,inner sep=1pt](a){\tiny Submits};
\end{tikzpicture}
\end{document}
编辑:添加了\scriptsize
更改 Bob 和 Alice 的字体大小的功能。