我希望你能帮我标记tikz
下面的code
内容回答被标记。
\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
\begin{tikzpicture}
\tikzset{declare function={hourstoangle(\h) = 90-(\h)*360/12;}}
\def\dialR{3cm} % dial radius
% dial
%\draw (0,0) circle[radius=\dialR];
%% hour tips
%\foreach \num in {1,...,12}{
%\draw ({hourstoangle(\num)}:\dialR)-- ++({hourstoangle(\num)}:-1mm);
%}
%% hour labels
%\foreach \num in {1,...,12}{
%\draw ({hourstoangle(\num)}:\dialR-5mm) node{\num};
%}
% arcs
\foreach \num in {0, 1, 3, 4, 6, 7, 9, 10}{
\pgfmathsetmacro\dist{\dialR+2mm+2mm*\num}
\draw
% two tips
({hourstoangle(\num)}:\dist pt-1mm) -- ({hourstoangle(\num)}:\dist pt+1mm)
({hourstoangle(\num+3)}:\dist pt-1mm) -- ({hourstoangle(\num+3)}:\dist pt+1mm)
% one arc
({hourstoangle(\num)}:\dist pt)
arc[start angle={hourstoangle(\num)},end angle={hourstoangle(\num+3)},radius=\dist pt];
}
\end{tikzpicture}
\end{document}
我想要的是
我希望你在中间标记tikz in the above
代码弧,这样如果重新定位弧,标签就会自动跟随。just [![like this][2]][2] and like this [answer is labelled][1]. I want the labels to be embedded in each
。
答案1
在弧线绘图中使用。您可以使用格式node[fill=white, midway, sloped, allow upside down, inner ysep=0pt]
在循环中为标签添加变量。此外,使用箭头提示(由提供)可以使端点更容易。\foreach
\foreach \num/\lab in {num1/lab1, ..., numn/labn}
Bar
arrows.meta
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
\tikzset{declare function={hourstoangle(\h) = 90-(\h)*360/12;}}
\def\dialR{3cm} % dial radius
\foreach \num/\lab in {0/label 1, 1/label 2, 3/label 3, 4/label 4, 6/label 5, 7/label 6, 9/label 7, 10/label 8}{
\pgfmathsetmacro\dist{\dialR+2mm+2mm*\num}
\draw[Bar-Bar]
({hourstoangle(\num)}:\dist pt)
arc[start angle={hourstoangle(\num)},end angle={hourstoangle(\num+3)},radius=\dist pt]node[fill=white, midway, sloped, allow upside down, inner ysep=0pt]{\lab};
}
\end{tikzpicture}
\end{document}