我需要帮助才能画好这幅画。我有点想法,但就是画不出来。
我需要绘制一个非局部随机游走(就像图片一样)。绘制过程本身非常简单:中间有一个 $x$,每个角都有一个 $x + vector*h$。此外,每个角上都有一个箭头,箭头上方(或下方)有一个询问符号
我用于局部随机游走的代码
\begin{document}
\begin{tikzpicture}[]
\draw (-3,0) -- (3,0) ;
\foreach \x/\y in {-3/{$x-e_{1}h$},3/{$x+e_{1}h$}}
\draw[shift={(\x,0)},color=black] (0pt,3pt) -- (0pt,-3pt)node[below] {\y};
\node[below right] at (3pt,-3pt) {$x$};
\draw (0,-3)`enter code here` -- (0,3) ;
\foreach \x/\y in {-3/{$x-e_{2}h$},3/{$x+e_{2}h$}}
\draw[shift={(0,\x)},color=black] (-3pt,0pt) -- (3pt,0pt)node[right] {\y};
\end{tikzpicture}
\end{document}
答案1
以下是针对您的问题的逐步解答。
首先,我用 绘制线条,\draw
并在 之后定义角度--++
,然后用 在箭头长度的一半处添加问号pos=0.5
,然后使用节点命令添加其他标签。您可以尝试像 这样的定位above, below, left, rigth
及其组合。
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[-stealth] (0,0) --++ (0:2) node[pos=0.5, above] {?} node[below] {$x+l_1 \cdot h$} node[fill=black, circle, scale=0.25] {};
\draw[-stealth] (0,0) --++ (45:2) node[pos=0.5, above] {?} node[right] {$x+(l_1-l_2) \cdot h$} node[fill=black, circle, scale=0.25] {};
\draw[-stealth] (0,0) --++ (90:2) node[pos=0.5, left] {?} node[above right] {$x+l_2 \cdot h$} node[fill=black, circle, scale=0.25] {};
\draw[-stealth] (0,0) --++ (135:2) node[pos=0.5, left] {?} node[left] {$x+(-l_1+l_2) \cdot h$} node[fill=black, circle, scale=0.25] {};
\draw[-stealth] (0,0) --++ (180:2) node[pos=0.5, below] {?} node[below] {$x-l_1 \cdot h$} node[fill=black, circle, scale=0.25] {};
\draw[-stealth] (0,0) --++ (225:2) node[pos=0.5, below] {?} node[left] {$x+(-l_1-l_2) \cdot h$} node[fill=black, circle, scale=0.25] {};
\draw[-stealth] (0,0) --++ (270:2) node[pos=0.5, right] {?} node[below left] {$x-l_2 \cdot h$} node[fill=black, circle, scale=0.25] {};
\draw[-stealth] (0,0) node[fill=white, opacity=0.5, below right] {x} --++ (315:2) node[pos=0.5, above] {?} node[right] {$x+(l_1-l_2) \cdot h$} node[fill=black, circle, scale=0.25] {};
\draw (-3,0) -- (3,0) node[right] {$h \cdot z^n$};
\draw (0,-3) -- (0,3);
\end{tikzpicture}
\end{document}
答案2
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{tikz}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\N}{6}
\pgfmathsetmacro{\angle}{360/\N}
\tikzset{structureline/.style={<->,black,thin}}
\foreach \i in {1,2,...,\N}
\foreach\j in{text}{
\draw[structureline] (0,0) -- (\i*\angle:4)node[label=\i*\angle:\j]{};
}
\end{tikzpicture}
\end{document}