答案1
pstricks
以下是带有和 的简短代码stackengine
:
\documentclass[border=3pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{pgffor}
\usepackage[usestackEOL]{ stackengine}
\usepackage{pst-node, pst-plot}
\begin{document}
\begin{pspicture}(-1,-2)(7,2)
\sffamily
\psset{labels=none, unit=2cm, ticksize=-1.5ex 1.5ex, tickwidth=0.8pt, labelsep=2ex, arrowinset=0.12}
\psaxes(0,0)(-0.5,0)(3.5,0)
\foreach \i/\sol in {0/\Centerstack[l]{Solution 1\\method 1}, 1/\Centerstack[l]{Sol 2\\med 2}, 2/\Centerstack[l]{Sol 3\\med 3}, 3/\Centerstack[l]{Sol 4\\med 4}}{\uput*[d](\i, 0){\sol}}
\pnodes{A}(0,0.5)(3,0.5)
\ncline{|<->|}{A0}{A1}\ncput*{k distance}
\end{pspicture}
\end{document}
答案2
的翻译伯纳德解答tikz
答案:
\documentclass[tikz, border=3mm]{standalone}
\usetikzlibrary{arrows.meta}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{tikzpicture}[
> = {Straight Barb[].Bar[width=3.2mm]},
every node/.append style = {inner sep=2mm, font= \sffamily,
fill=white, align=center}
]
\def\k{1.5}
\draw[thick] (-\k*0.5,0) -- + (\k*4,0);
\foreach \i [count=\j from 0] in {{Solution 1\\method 1}, {Sol 2\\med 2},
{Sol 3\\med 3}, {Sol 4\\med 4}}
{\draw (\k*\j,1mm) -- + (0,-2mm) node[below] {\i};}
\draw[<->] (0,0.5) -- node {k distance} (\k*3,0.5);
\end{tikzpicture}
\end{document}
答案3
另一种简单的方法是Tikz
。
\documentclass[border=5mm, tikz]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[math]{iwona}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}
\draw[latex-latex,thick] (-1,0) -- (8.5,0);
\draw[thick] (0,0)--(0,.75);
\draw[thick] (2.5,0)--(2.5,.25);
\draw[thick] (5,0)--(5,.25);
\draw[thick] (7.5,0)--(7.5,.75);
\draw[latex-, thick] (0,.5) -- (2.75,.5);
\draw[-latex, thick] (4.75,.5) -- (7.5,.5);
\node[circle,fill,inner sep=1.5pt] at (0,0) {};
\node[circle,fill,inner sep=1.5pt] at (7.5,0){};
\node[circle,fill,inner sep=1.5pt] at (2.5,0){};
\node[circle,fill,inner sep=1.5pt] at (5,0){};
\node at (3.75,.5) {k distance};
\node at (0,0) [below] {$\begin{array}{c} Solution\,1 \\ method\,1 \end{array}$};
\node at (2.5,0) [below] {$\begin{array}{c} Sol\,2 \\ med\,2 \end{array}$};
\node at (5,0) [below] {$\begin{array}{c} Sol\,3 \\ med\,3 \end{array}$};
\node at (7.5,0) [below] {$\begin{array}{c} Sol\,4 \\ med\,4 \end{array}$};
\end{tikzpicture}
\end{document}