我有以下代码来创建带有事件标签的时间线。在第二张图中,在事件之间$(\tau_1+\frac{x_1}{K_1},x_2)$
,我想在下面放置一个花括号,表示$\pi_1=...$
在下面$(\tau_2,\tau)$
我想放置另一个带有不同标签的花括号。
在我的代码中,运行时,括号变得丑陋,不像通常的那种时尚。我尝试过改变幅度,但无济于事。
\usepackage{tikz}
\usetikzlibrary{snakes, arrows, automata, positioning, calc, decorations.pathreplacing}
\begin{figure}
\quad\quad\quad\quad
\begin{tikzpicture}
\draw (0.5,0) -- (7,0);
\draw[xshift=0.45 cm, thick] (5pt,5pt) -- (5pt,-5pt)node[above=0.3cm,fill=white] {0};
\draw[xshift=1 cm, thick] (5pt,5pt) -- (5pt,-5pt) node[above=0.3cm,fill=white] {$\tau_1$};
\draw[xshift=2.5 cm, thick] (5pt,5pt) -- (5pt,-5pt) node[above=0.3cm,fill=white] {$\tau_2$};
\draw[xshift=3.5 cm, thick] (5pt,5pt) -- (5pt,-5pt) node[above=0.3cm,fill=white] {$\tau_1+\frac{x_1}{K_1}$};
\draw[xshift=6.5cm, thick] (5pt,5pt) -- (5pt,-5pt) node[above=0.3cm,fill=white] {$\tau$};
\end{tikzpicture}
\quad\quad\quad\quad
\begin{tikzpicture}
\draw (0.5,0) -- (7,0);
\draw[xshift=0.45 cm, thick] (5pt,5pt) -- (5pt,-5pt) node[above=0.3cm,fill=white] {0};
\draw[xshift=1 cm, thick] (5pt,5pt) -- (5pt,-5pt) node[above=0.3cm,fill=white] {$\tau_1$};
\draw[xshift=2.5 cm, thick] (5pt,5pt) -- (5pt,-5pt) node[above=0.3cm,fill=white] {$\tau_1+\frac{x_1}{K_1}$};
\draw[xshift=3.5 cm, thick] (5pt,5pt) -- (5pt,-5pt) node[above=0.3cm,fill=white] {$\tau_2$};
\draw [decorate,decoration={brace,amplitude=-10pt},xshift=0pt,yshift=-1pt, mirror]
(3.5,-0.5) -- (6.5,-0.5) node [black,midway, yshift=-0.6cm] {\footnotesize $\pi_i=1+q(\pi_1-1)$};
\draw[xshift=6.5 cm, thick] (5pt,5pt) -- (5pt,-5pt) node[above=0.3cm,fill=white] {$\tau$};
\end{tikzpicture}
\end{figure}
答案1
mirror
是 的一个选项decoration={}
。另外,不要使用负振幅:
\documentclass[tikz]{standalone}
\usetikzlibrary{decorations.pathreplacing,calc}
\begin{document}
\begin{tikzpicture}
\coordinate (A) at (0.45,0);
\coordinate (B) at (1,0);
\coordinate (C) at (2.5,0);
\coordinate (D) at (3.5,0);
\coordinate (E) at (6.5,0);
\draw (0,0) -- (7,0);
\draw[thick] ($(A)+(0,5pt)$) node[above] {$0$} -- ($(A)-(0,5pt)$);
\draw[thick] ($(B)+(0,5pt)$) node[above] {$\tau_1$} -- ($(B)-(0,5pt)$);
\draw[thick] ($(C)+(0,5pt)$) node[above] {$\tau_1+\frac{x_1}{K_1}$} -- ($(C)-(0,5pt)$);
\draw[thick] ($(D)+(0,5pt)$) node[above] {$\tau_2$} -- ($(D)-(0,5pt)$);
\draw[thick] ($(E)+(0,5pt)$) node[above] {$\tau$} -- ($(E)-(0,5pt)$);
\draw[decorate,decoration={brace,amplitude=5pt,mirror,raise=3mm}] (C) -- (D) node [black,midway,yshift=-7mm] {\footnotesize $\pi_i=1+q(\pi_1-1)$};
\end{tikzpicture}
\end{document}
答案2
如果您喜欢以下内容,请查看:
\documentclass[border=3mm,
tikz,
preview
]{standalone}
\usetikzlibrary{decorations.pathreplacing
}
\begin{document}
\begin{tikzpicture}
\draw (0,0) -- (7,0);
\foreach \i/\j in {0.45/0,1/$\tau_1$,2.5/$\tau_2$,3.5/$\tau_1+\frac{x_1}{K_1}$,6.5/$\tau$}
\draw (\i,-5pt) -- + (0,10pt) node[above] {\j};
\end{tikzpicture}
\begin{tikzpicture}[
decoration={brace,amplitude=10pt,raise=8pt,mirror}
]
\draw (0,0) -- (7,0);
\foreach \i/\j in {0.45/0,1/$\tau_1$,2.5/$\tau_2$,3.5/$\tau_1+\frac{x_1}{K_1}$,6.5/$\tau$}
\draw (\i,-5pt) -- + (0,10pt) node[above] {\j};
\draw[decorate]
(3.5,0) -- node[below=15pt] {\footnotesize $\pi_i=1+q(\pi_1-1)$} ++ (3,0) ;
\end{tikzpicture}
\end{document}
正如您所看到的,我稍微重新组织了您的代码,并使其更短......