
我在論壇上閱讀了一些主題,但仍然不知道如何繪製這樣的圖表
我知道我可以只插入圖像,但我認為自己繪製它會更好,而且我還必須更改變數(我需要用 T 更改 S,用 J 更改 X,用 X 更改 J)
這就是我到目前為止所取得的成就
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.5}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis lines=middle, axis equal, title=test, xlabel={Time}, ylabel=.{States}]
\addplot table {
x y
1.7 4.3
0 4.3
1.7 4
2.3 4
2.3 5.2
3.1 5.2
3.1 4.5
3.8 4.5
3.8 3.8
4.7 3.8
4.7 5.5
5.8 5.5
};
\end{axis}
\end{tikzpicture}
\end{document}
我仍然需要“x”軸上的刻度與函數的跳轉點相關,並將它們命名為“T_0,T_1,... T_n”(注意,跳轉長度是隨機的,並且必須是)。此外,有誰知道如何從函數中刪除右邊的點,只留下左邊的點?
PS:當然我會添加使用此圖像的參考書目參考
給大家一個大大的擁抱!
答案1
這可能不是最靈活的解決方案,但我認為它相當簡單。 (稍後您可能會從其他人那裡得到更好的解決方案。)它也不使用pgfplots
,只是簡單的 TikZ。
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}[
axis/.style={thick,Latex-Latex},
xbar/.style={-Circle}
]
\draw [axis] (0,4) node[above] {States} |- (7,0) node[below] {time};
\foreach \y/\txt in {1/J_n=k,2/J_0=i,2.5/J_1=j}
\node [left=3mm] at (0,\y) {$\{\txt\}$};
\foreach [count=\i] \x/\txt in {0/0,1/1,1.8/2,3.2/n,5/n+1}
{
\node [below=3mm] (S\i) at (\x,0) {$S_{\txt}$};
\draw (\x,0) -- ++(0,{ifthenelse(\x>0,-3pt,0)});
}
\foreach \xA/\xB/\y in {0/1/2,1/1.8/2.5,3.2/5/1}
\draw [xbar] (\xA,\y) -- (\xB,\y);
\path (S3) -- node (dots1) {$\dots$} (S4);
\node [right=2mm] (dots2) at (S5.east) {$\dots$};
\node at (0,1.5 -| dots1) {$\dots$};
\node at (0,1 -| dots2) {$\dots$};
\node [below left] at (7,4) {
\begin{tabular}{c @{ : }l}
$(X_n)$ & sojourn time \\
$(J_n)$ & states of the system \\
$(S_n)$ & jump time
\end{tabular}};
\end{tikzpicture}
\end{document}