我正在尝试复制此图表
这是我的图表代码(底部的图片)。任何帮助都将不胜感激。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[step=1cm,gray,very thin,dashed] (-6,0) grid (6,4);
\draw[black,very thick, <->] (-6,0)--(6,0) node[anchor=north west]{$x$ space};
\draw[black,very thick, <->] (0,0)--(0,5)node[anchor=north east]{ $\tau$ time};
\draw (\x cm, 1pt)--(\x cm, -1pt)node[anchor=north]{$\x$};
\draw (\y cm, 1pt)--(\y cm, -1pt)node[anchor=north]{$\y$};
\end{tikzpicture}
\end{document}
答案1
对于括号,您可以使用同名的装饰,这需要decorations.pathreplacing
库。除此之外,它只是重复你所做的。
\documentclass{article}
\usepackage{geometry}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}[>=stealth]
\draw[step=1cm,gray,very thin,dashed] (-6,0) grid (6,4);
\draw[black,very thick, <->] (-6,0)node[left] {space} --(6,0) node[right]{$x$};
\draw[black,very thick, ->] (0,0)--(0,5)node[above,align=center]{time\\$\tau$}
node[below right]{$\widetilde{T}=Mk$};
\draw[decoration={brace,raise=1pt,amplitude=4pt},decorate] (-2,2) -- node[below=2.5pt]{$h$}(-3,2);
\draw[decoration={brace,raise=1pt,amplitude=4pt},decorate] (-2,3) -- node[right=2.5pt]{$g$}(-2,2);
\draw (-0.1,2) -- ++ (0.2,0) node[below right] {$\tau_{n+1}$}
(-0.1,3) -- ++ (0.2,0) node[above right] {$\tau_{n}$};
\begin{scope}[nodes={text height=0.8em}]
\foreach \X [count=\Y starting from 2] in {x_{i+1},x_i}
{\draw (-\Y,.1) -- ++ (0,-0.2) node[below] {$\X$}; }
\path foreach \X in {-,}
{(\X4.8,-0.1) node[below] {$\X R=\X Nh$}}
(0,-0.1) node[below]{$0$};
\end{scope}
\end{tikzpicture}
\end{document}