我想将我绘制的圆标记为圆弧的集合,并希望将其标记在nodes
沿圆曲线流动的部分上。我目前拥有的horizontal
标签不沿圆曲线流动。
\documentclass{article}
\usepackage{tikz, xcolor}
\begin{document}
\begin{tikzpicture}
\draw[|-|] (90.0:3.0) arc(90.0:67.5:3.0);
\draw[|-|] (67.5:3.0) arc(67.5:45.0:3.0);
\draw[|-|] (45.0:3.0) arc(45.0:22.5:3.0);
\draw[|-|] (22.5:3.0) arc(22.5:00.0:3.0);
\draw[|-|] (00.0:3.0) arc(00.0:-22.5:3.0);
\draw[|-|] (-22.5:3.0) arc(-22.5:-45.0:3.0);
\draw[|-|] (-45.0:3.0) arc(-45.0:-67.5:3.0);
\draw[|-|] (-67.5:3.0) arc(-67.5:-90.0:3.0);
\draw[|-|] (-90.0:3.0) arc(-90.0:-112.5:3.0);
\draw[|-|] (-112.5:3.0) arc(-112.5:-135.0:3.0);
\draw[|-|] (-135.0:3.0) arc(-135.0:-157.5:3.0);
\draw[|-|] (-157.5:3.0) arc(-157.5:-180.0:3.0);
\draw[|-|] (-180.0:3.0) arc(-180.0:-202.5:3.0);
\draw[|-|] (-202.5:3.0) arc(-202.5:-225.0:3.0);
\draw[|-|] (-225.0:3.0) arc(-225.0:-247.5:3.0);
\draw[|-|] (-247.5:3.0) arc(-247.5:-270.0:3.0);
\node at (90.0:3.45) {\color{blue}{$x_{n}$}};
\node at (67.5:3.45) {\color{blue}{$x_1$}};
\node at (45.0:3.45) {\color{blue}{$x_2$}};
\node at (22.5:3.45) {\color{blue}{$\cdots$}};
\node at (00.0:3.45) {\color{blue}{$x_l$}};
\node at (-22.5:3.45) {\color{blue}{$x_{l+1}$}};
\node at (-45.0:3.45) {\color{blue}{$x_{l+2}$}};
\node at (-67.5:3.45) {\color{blue}{$\cdots$}};
\node at (-90.0:3.45) {\color{blue}{$x_{i}$}};
\node at (-112.5:3.45) {\color{blue}{$x_{i+1}$}};
\node at (-135.0:3.45) {\color{blue}{$x_{i+2}$}};
\node at (-157.5:3.45) {\color{blue}{$\cdots$}};
\node at (-180.0:3.45) {\color{blue}{$x_{n-l}$}};
\node at (-202.5:3.45) {\color{blue}{$\cdots$}};
\node at (-225.0:3.45) {\color{blue}{$x_{n-2}$}};
\node at (-247.5:3.45) {\color{blue}{$x_{n-1}$}};
%\foreach \i in {1,...,16} \node at ({112.5-22.5*\i}:3.45) {\color{blue}{$x_{\i}$}};
%\foreach \i in {17,...,21} \node at ({112.5-22.5*\i}:2.55) {\color{red}{$x_{\i}$}};
%\node at (90.0:2.65) {\color{red}{$x_{n}$}};
\node at (67.5:2.65) {\color{red}{$x_{n+1}$}};
\node at (45.0:2.65) {\color{red}{$\cdots$}};
\node at (22.5:2.65) {\color{red}{$x_{n+l-1}$}};
\node at (00.0:2.65) {\color{red}{$x_{n+l}$}};
%\node at (-22.5:2.65) {\color{red}{$x_{n+1-2}$}};
%\node at (-45.0:2.65) {\color{red}{$x_{n+l-1}$}};
%\node at (-67.5:2.65) {\color{red}{$x_{n+l}$}};
%\draw[|-|] (157.5:2.4) arc(157.5:67.5:2.4) node[midway,fill=white]{$B_{n-3}$};
\draw[|-|] (135:2.4) arc(135:45.0:2.4) node[fill=white, midway, sloped, allow upside down, inner ysep=0pt]{$B_{n-2}$};
\draw[|-|] (112.5:2.0) arc(112.5:22.5:2.0) node[fill=white, midway, sloped, allow upside down, inner ysep=0pt]{$B_{n-1}$};
\draw[|-|] (90.0:1.6) arc(90.0:00.0:1.6) node[fill=white, midway, sloped, allow upside down, inner ysep=0pt]{$B_{n}$};
\draw[|-|] (90:4.0) arc(90:0:4.0) node[fill=white, midway, sloped, allow upside down, inner ysep=0pt]{$B_1$};
\draw[|-|] (60:4.4) arc(60:-30:4.4) node[fill=white, midway, sloped, allow upside down, inner ysep=0pt]{$B_2$};
\draw[|-|] (30:4.8) arc(30:-60:4.8) node[fill=white, midway, sloped, allow upside down, inner ysep=0pt]{$B_3$};
\draw[|-|] (180:4.8) arc(180:90:4.8) node[fill=white, midway, sloped, allow upside down, inner ysep=0pt]{$B_{n-l+1}$};
\draw[|-|] (210:4.4) arc(210:120:4.4) node[fill=white, midway, sloped, allow upside down, inner ysep=0pt]{$B_{n-l}$};
\draw[|-|] (240:4.0) arc(240:150:4.0) node[fill=white, midway, sloped, allow upside down, inner ysep=0pt]{$B_{n-l-1}$};
\end{tikzpicture}
\end{document}
我想要的是
我想要highlighted
沿着圆曲线标记各个部分。
笔记
我是新手,目前我更希望我的代码像这样,否则我会被更复杂的代码搞糊涂。因此,如果您要回答我的问题,只需将您的代码添加到我的代码中,不要删除我的代码,因为只有高级人text-nician
才能理解复杂的代码。
答案1
如果有人想要一种更自动化的方法。
我正在使用ext.arrows
我的tikz-ext
包(> 0.5.1)的库来获得“居中”栏提示。
使用切换时,当我们沿着弧线sloped
放置节点时,我们根本不需要计算任何旋转。x_…
如果您将节点沿着小弧放置,那么您实际上已经可以使用代码执行此操作了:
\draw[|-|, sloped, allow upside down] (67.5:3.0) arc(67.5:45.0:3.0)
node[at start, above, blue] {$\mathstrut x_1 $}
node[at start, below, red] {$\mathstrut x_{n+1}$};
代码
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{ext.arrows}% for Centered Bar
\tikzset{
pics/arrow/.style={/tikz/sloped, /tikz/allow upside down,
code=\pgfarrowdraw{#1}}, pics/arrow/.default=>}
\begin{document}
\begin{tikzpicture}[CB/.tip=Centered Bar]
\draw[sloped, allow upside down] (90-360/16:3cm)
arc[start angle=90-360/16, delta angle=-360, radius=3cm]
foreach[count=\i from 0] \BLUE/\RED in {
x_1 / x_{n+1},
x_2 / \dots,
\dots / x_{n+l-1},
x_l / x_{n+l},
x_{l+1} / ,
x_{l+2} / ,
\dots / ,
x_i / ,
x_{i+1} / ,
x_{i+2} / ,
\dots / ,
x_{n-l} / ,
\dots / ,
x_{n-2} / ,
x_{n-1} / ,
x_n /
}{
[nodes={pos=\i/16}]
pic {arrow=CB}
node[above, blue]{$\mathstrut\BLUE$}
node[below, red] {$\mathstrut\RED$}
} -- cycle;
\scoped[
nodes={midway, fill=white},
allow upside down, sloped, delta angle=-90, inner ysep=+0pt]
\foreach \Radius/\deltaRadius/\LIST in {
4cm / .4cm/{ 90/1, 60 /2, 30/3},
4cm / .4cm/{240/n-l-1, 210 /n-l, 180/n-l+1},
2.2cm/-.4cm/{135/n-2, 112.5/n-1, 90/n}}
\foreach[count=\i from 0]\startAngle/\SUB in \LIST
\draw[CB-CB] (\startAngle:\Radius+\deltaRadius*\i)
arc[start angle=\startAngle, radius=\Radius+\deltaRadius*\i]
node {$B_{\SUB}$};
\end{tikzpicture}
\end{document}
输出
答案2
答案3
您可以在绘制弧线时放置节点;您不必\node
单独使用该命令。node[sloped, allow upside down, above=1mm, pos=1, blue]{<contents>}
为每个弧线添加蓝色节点和node[sloped, allow upside down, below=1mm, pos=1, red]{<contents>}
红色节点。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[|-|] (90.0:3.0) arc(90.0:67.5:3.0) node[sloped, allow upside down, above=1mm, pos=1, blue]{$x_1$}node[sloped, allow upside down, below=1mm, pos=1, red]{$x_{n+1}$};
\draw[|-|] (67.5:3.0) arc(67.5:45.0:3.0) node[sloped, allow upside down, above=1mm, pos=1, blue]{$x_2$}node[sloped, allow upside down, below=1mm, pos=1, red]{$\cdots$};
\draw[|-|] (45.0:3.0) arc(45.0:22.5:3.0) node[sloped, allow upside down, above=1mm, pos=1, blue]{$\cdots$}node[sloped, allow upside down, below=1mm, pos=1, red]{$x_{n+l-1}$};
\draw[|-|] (22.5:3.0) arc(22.5:00.0:3.0) node[sloped, allow upside down, above=1mm, pos=1, blue]{$x_l$}node[sloped, allow upside down, below=1mm, pos=1, red]{$x_{n+l}$};
\draw[|-|] (00.0:3.0) arc(00.0:-22.5:3.0) node[sloped, allow upside down, above=1mm, pos=1, blue]{$x_{l+1}$};
\draw[|-|] (-22.5:3.0) arc(-22.5:-45.0:3.0) node[sloped, allow upside down, above=1mm, pos=1, blue]{$x_{l+2}$};
\draw[|-|] (-45.0:3.0) arc(-45.0:-67.5:3.0) node[sloped, allow upside down, above=1mm, pos=1, blue]{$\cdots$};
\draw[|-|] (-67.5:3.0) arc(-67.5:-90.0:3.0) node[sloped, allow upside down, above=1mm, pos=1, blue]{$x_{i}$};
\draw[|-|] (-90.0:3.0) arc(-90.0:-112.5:3.0) node[sloped, allow upside down, above=1mm, pos=1, blue]{$x_{i+1}$};
\draw[|-|] (-112.5:3.0) arc(-112.5:-135.0:3.0) node[sloped, allow upside down, above=1mm, pos=1, blue]{$x_{i+2}$};
\draw[|-|] (-135.0:3.0) arc(-135.0:-157.5:3.0) node[sloped, allow upside down, above=1mm, pos=1, blue]{$\cdots$};
\draw[|-|] (-157.5:3.0) arc(-157.5:-180.0:3.0) node[sloped, allow upside down, above=1mm, pos=1, blue]{$x_{n-l}$};
\draw[|-|] (-180.0:3.0) arc(-180.0:-202.5:3.0) node[sloped, allow upside down, above=1mm, pos=1, blue]{$\cdots$};
\draw[|-|] (-202.5:3.0) arc(-202.5:-225.0:3.0) node[sloped, allow upside down, above=1mm, pos=1, blue]{$x_{n-2}$};
\draw[|-|] (-225.0:3.0) arc(-225.0:-247.5:3.0) node[sloped, allow upside down, above=1mm, pos=1, blue]{$x_{n-1}$};
\draw[|-|] (-247.5:3.0) arc(-247.5:-270.0:3.0) node[sloped, allow upside down, above=1mm, pos=1, blue]{$x_{n}$};
%%%
\draw[|-|] (135:2.4) arc(135:45.0:2.4) node[fill=white, midway, sloped, allow upside down, inner ysep=0pt]{$B_{n-2}$};
\draw[|-|] (112.5:2.0) arc(112.5:22.5:2.0) node[fill=white, midway, sloped, allow upside down, inner ysep=0pt]{$B_{n-1}$};
\draw[|-|] (90.0:1.6) arc(90.0:00.0:1.6) node[fill=white, midway, sloped, allow upside down, inner ysep=0pt]{$B_{n}$};
\draw[|-|] (90:4.0) arc(90:0:4.0) node[fill=white, midway, sloped, allow upside down, inner ysep=0pt]{$B_1$};
\draw[|-|] (60:4.4) arc(60:-30:4.4) node[fill=white, midway, sloped, allow upside down, inner ysep=0pt]{$B_2$};
\draw[|-|] (30:4.8) arc(30:-60:4.8) node[fill=white, midway, sloped, allow upside down, inner ysep=0pt]{$B_3$};
\draw[|-|] (180:4.8) arc(180:90:4.8) node[fill=white, midway, sloped, allow upside down, inner ysep=0pt]{$B_{n-l+1}$};
\draw[|-|] (210:4.4) arc(210:120:4.4) node[fill=white, midway, sloped, allow upside down, inner ysep=0pt]{$B_{n-l}$};
\draw[|-|] (240:4.0) arc(240:150:4.0) node[fill=white, midway, sloped, allow upside down, inner ysep=0pt]{$B_{n-l-1}$};
\end{tikzpicture}
\end{document}