答案1
使用 TikZ:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\tikzset{
mypoint/.style={
circle,
draw,
inner sep=.3mm
},
whitepoint/.style={
fill=white,
mypoint
},
blackpoint/.style={
fill=black,
mypoint
},
textnode/.style={
text height=2.5ex,
text depth=1ex
},
}
\begin{document}
\begin{tikzpicture}[scale=2]
\draw[-latex] (-.5,0) -- (3,0); \draw[dashed, lightgray] (0,0) -- (0,.8);
\draw[dashed, lightgray] (1,0) -- (1,.8);
\draw[dashed, lightgray] (1.732,0) -- (1.732,.9);
\draw[dashed, lightgray] (2,0) -- (2,.9);
\foreach \x in {0,1,1.732,2}
\node[blackpoint] at (\x,0){};
\foreach \x in {0,1,2}
\node[textnode] at (\x,-.2) {\x};
\node[textnode] at (1.732,-.2) {$\sqrt{3}$};
\node[textnode] at (2.9,-.2) {$t$};
\node[whitepoint] (h01) at (0,.2){};
\draw (0,.2) node[whitepoint] {} -- (3,.2);
\foreach \x in {.3,.4,...,.7}
\draw (0,\x) node[whitepoint] {} -- (1,\x) node[blackpoint] {};
\draw (1,.8) node[whitepoint] {} -- node[above]{$H_1$} (1.732,.8) node[blackpoint] {};
\draw (1.732,.9) node[whitepoint] {} -- node[above]{$H_2$} (2,.9) node[blackpoint] {};
\draw (0,.1) -- ++(-.1,0) -- node[left]{$H_0$} ++(0,.7) -- ++(.1,0);
\end{tikzpicture}
\end{document}
答案2
这是一个简单的 PSTricks 解决方案,仅用于娱乐或比较目的。
\documentclass[pstricks,border=12pt,12pt]{standalone}
\begin{document}
\psset{xunit=3cm,yunit=1.2cm}
\begin{pspicture}(-.25,-.5)(2.25,2.25)
\psline[arrowinset=0]{->}(-.25,0)(2.25,0)
\psset{linecolor=gray,linestyle=dashed,dash=2pt 1pt}
\psline(0,0)(0,1.7)
\psline(1,0)(1,1.7)
\psline(!3 sqrt 0)(!3 sqrt 1.9)
\psline(2,0)(2,1.9)
\psset{linecolor=black,linestyle=solid}
\foreach \i/\j in {0/0,1/1,{3/\sqrt{3}},4/2}{%
\pscircle*(!\i\space sqrt 0){2pt}
\rput(!\i\space sqrt -.35){$\j$}}
\rput(2.2,-.35){$t$}
\psline{o-}(0,.5)(2.25,.5)
\foreach \i in {1,2,...,5}{\psline{o-*}(!0 .5 0.2 \i\space mul add)(!1 .5 0.2 \i\space mul add)}
\psline{o-*}(1,1.7)(!3 sqrt 1.7)
\psline{o-*}(!3 sqrt 1.9)(2,1.9)
\rput(1.35,1.9){$H_1$}
\rput(!3 sqrt .15 add 2.1){$H_2$}
\rput(-.17,1){$H_0$}
\psline(0,1.6)(-.05,1.6)(-.05,.4)(0,.4)
\end{pspicture}
\end{document}
答案3
arrows
对于使用(和calc
的)稍微不同的 TikZ 解决方案sqrt(3)
:
\documentclass[tikz]{standalone}
\usetikzlibrary{arrows,calc}
\begin{document}
\begin{tikzpicture}[scale=3]
% Vertical dashed lines
\draw[dashed, lightgray] (0,0) -- (0,.8);
\draw[dashed, lightgray] (1,0) -- (1,.8);
\draw[dashed, lightgray] ({sqrt(3)},0) -- ({sqrt(3)},.9);
\draw[dashed, lightgray] (2,0) -- (2,.9);
% Axis
\draw [-latex,shorten >=-3pt] (-.2,0) -- (3,0) node [below] {$\phantom{\sqrt{3}}t\phantom{\sqrt{3}}$};
\foreach \x in {0,1,2}
\node at (\x,0) {$\bullet$}
node at (\x,0) [below] {$\phantom{\sqrt{3}}\x\phantom{\sqrt{3}}$};
\node at ({sqrt(3)},0) {$\bullet$}
node at ({sqrt(3)},0) [below] {$\sqrt{3}$};
% Horizontal lines
\draw [{*[fill=white]}-,shorten <=-2.4pt] (0,.2) -- (3,.2);
\foreach \x in {.3,.4,...,.7}
\draw [{*[fill=white]}-*,shorten >=-2.4pt,shorten <=-2.4pt] (0,\x) -- (1,\x) ;
\draw [{*[fill=white]}-*,shorten >=-2.4pt,shorten <=-2.4pt] (1,.8) -- node [above] {$H_1$} ({sqrt(3)},.8) ;
\draw [{*[fill=white]}-*,shorten >=-2.4pt,shorten <=-2.4pt] ({sqrt(3)},.9) -- node [above] {$H_2$} (2,.9) ;
\draw (0,.1) -- (-.1,.1) -- node[left]{$H_0$} (-.1,.8) -- (0,.8);
\end{tikzpicture}
\end{document}
而输出结果则稍微不太理想(项目符号不居中,且大小与箭头不同):
此外,缩短只是猜测,可能不是像素完美的。
编辑:另一种解决方案arrows.meta
解决了上述代码的大部分问题,但在某些部分不太优雅:
\documentclass[tikz]{standalone}
\usetikzlibrary{arrows.meta,calc}
\begin{document}
% Arrows are shifted by half their width
\tikzset{open/.style={{Circle[fill=white]}-,shorten <=-1.196825pt-1.595769\pgflinewidth}}
\tikzset{close/.style={-{Circle},shorten >=-1.196825pt-1.595769\pgflinewidth]}}
\tikzset{openclose/.style={{Circle[fill=white]}-{Circle},shorten <=-1.196825pt-1.595769\pgflinewidth,shorten >=-1.196825pt-1.595769\pgflinewidth]}}
\begin{tikzpicture}[scale=2]
% Vertical dashed lines
\draw[dashed, lightgray] (0,0) -- (0,.8);
\draw[dashed, lightgray] (1,0) -- (1,.8);
\draw[dashed, lightgray] ({sqrt(3)},0) -- ({sqrt(3)},.9);
\draw[dashed, lightgray] (2,0) -- (2,.9);
% Axis
\draw [close] (-.2,0) -- (0,0) node [below] {$\phantom{\sqrt{3}}0\phantom{\sqrt{3}}$};
\draw [close] (0,0) -- (1,0) node [below] {$\phantom{\sqrt{3}}1\phantom{\sqrt{3}}$};
\draw [close] (1,0) -- ({sqrt(3)},0) node [below] {$\sqrt{3}$};
\draw [close] ({sqrt(3)},0) -- (2,0) node [below] {$\phantom{\sqrt{3}}2\phantom{\sqrt{3}}$};
\draw [-latex,shorten >=-3pt] (2,0) -- (3,0) node [below] {$\phantom{\sqrt{3}}t\phantom{\sqrt{3}}$};
% Horizontal lines
\draw [open] (0,.2) -- (3,.2);
\foreach \x in {.3,.4,...,.7}
\draw [openclose] (0,\x) -- (1,\x) ;
\draw [openclose] (1,.8) -- node [above] {$H_1$} ({sqrt(3)},.8) ;
\draw [openclose] ({sqrt(3)},.9) -- node [above] {$H_2$} (2,.9) ;
\draw (0,.1) -- (-.1,.1) -- node[left]{$H_0$} (-.1,.8) -- (0,.8);
\end{tikzpicture}
\end{document}
答案4
使用 Asymptote 进行一点小改动。编译http://asymptote.ualberta.ca/
size(300,100,false);
defaultpen(linewidth(0.6bp));
dotfactor=7;
real s=0.1;
// Last drawing
draw((0,0)--(0,0.2+6s)^^(1,0)--(1,0.2+6s)^^
(sqrt(3),0)--(sqrt(3),0.2+7s)^^(2,0)--(2,0.2+7s),linetype(new real[]{7,7})+gray);
draw(Label("$t$",Relative(.96)),(-0.2,0)--(2.8,0),Arrow);
dot("$0$",(0,0),2S,Fill());
dot("$1$",(1,0),2S,Fill());
dot("$\sqrt{3}$",(sqrt(3),0),S,Fill());
dot("$2$",(2,0),2S,Fill());
draw((0,0.2)--(2.8,0.2));
dot((0,0.2),Fill(white));
for (int i=1; i<=5 ; i=i+1)
{
draw((0,0.2+i*s)--(1,0.2+i*s));
dot((0,0.2+i*s),Fill(white));
dot((1,0.2+i*s),Fill());
}
draw(Label("$H_1$",Relative(.4),LeftSide),(1,0.2+6s)--(sqrt(3),0.2+6s));
dot((1,0.2+6s),Fill(white));
dot((sqrt(3),0.2+6s),Fill());
draw(Label("$H_2$",LeftSide),(sqrt(3),0.2+7s)--(2,0.2+7s));
dot((sqrt(3),0.2+7s),Fill(white));
dot((2,0.2+7s),Fill());
draw(Label("$H_0$"),(0,0.2+5.5s)--(-s/2,0.2+5.5s)--(-s/2,0.2+-0.5s)--(0,0.2+-0.5s));