![如何编辑此地图?](https://linux22.com/image/395736/%E5%A6%82%E4%BD%95%E7%BC%96%E8%BE%91%E6%AD%A4%E5%9C%B0%E5%9B%BE%EF%BC%9F.png)
我想制作类似下面的折线图,但我只想用文字替换字母和数字。有什么办法吗?
这是原始代码:
\begin{tikzpicture}
\path[draw, thick, -] (-.3,0) -- (3.3,0);
\foreach \x in {0,...,3}{
\path[draw, thick] (\x,0) -- ++(0,-.15) node [below] {\x};
}
\foreach \x/\name in {0/A,.5/B,1/C,1}{
\path[draw, fill=blue] (\x,0) circle[radius=2pt] node [above=2 mm, blue] {\name};
}
\end{tikzpicture}
我尝试将其编辑0
成\foreach \x/\name in {0/A,.5/B,1/C,1}
一个单词,但是 Latex 无法编译它。
答案1
只需用单词替换字母和数字即可。对于放置单词,您可以定义新的计数器或定义箭头上距离\x/\name
的组合\x
。例如,正如我在以下 MWE 中所做的那样:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\noindent
\begin{tikzpicture}[x=15mm]
\path[draw, thick, ->] (-.3,0) -- (6.3,0);
\foreach \i [count=\x] in {an, ban, pet, podgan, štiri, miši}%
{
\draw[thick] (\x,0) -- ++(0,-.15)
node [text height=1.5ex, text depth=0.5ex, anchor=north] {\i};
}
\foreach \x/\name in {0/word, .6/word, 1/word, 1.5/word,2/word,
2.3/word,3/word, 3.3/word,4/word, 4.6/word,
5/word, 5.5/word, 6/word}%
{
\draw[fill=blue] (\x,0) circle[radius=2pt]
node [above=2 mm, blue, anchor=west, rotate=45] {\name};
}
\end{tikzpicture}
\end{document}
我理解你的问题正确吗?