我必须绘制星形部分,但我不知道如何填充我所绘制的圆弧之间的区域。以下是代码
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw [help lines](0,0) grid (10,10);
\draw [thick] (5,0) -- (1,8);
\draw [thick] (5,0) -- (9,8);
\draw [thick] (5,0) ++(60.43:8.94) arc (60.43:116.57:8.94);
\draw [thick] (5,0) ++(63.43:3) arc (63.43:116.57:3) node[left,sloped,rotate=35,font=\footnotesize]{$\approx2\rho_0$};
\draw [thick] (5,0) ++(59:5) arc (59:116.57:5) node[left,sloped,rotate=35,font=\footnotesize]{$\approx0.5\rho_0$};
\draw [thick] (5,0) ++(63.43:7) arc (63.43:116.57:7);
\draw [thick] (5,0) ++(60.43:8.5) arc (60.43:116.57:8.5);
\draw [thick] (5,0) -- (5.35,-0.22);
\draw [<->](9,7.518) -- (9.175,7.88) node[midway,right,sloped,rotate=-90] {10 cm};;
\draw [<->](7.43,4.37) -- (9,7.518) node[midway,below,sloped] {(1-2) km};
\draw [<->](5.175,-0.11) -- (7.43,4.37) node[midway,below,sloped] {(9-12) km};
\node at (5, 0) [left,rotate=35,font=\footnotesize]{$(3-9)\rho_0$};
\end{tikzpicture}
\end{document}
我是 Tikz 的新手,所以不太熟练,谢谢!
答案1
如果每个部分/环都应该填充不同的颜色,那么您可以从外面绘制它们,部分覆盖较大的部分。
我正在使用该siunitx
包及其…range
宏。
这ρ在原点处有点欺骗性,因为它使用 0.0001(即 1µm)的半径来获得该节点的正确方向。
代码
\documentclass[tikz]{standalone}
\usepackage{siunitx}
\sisetup{range-phrase=\dots, range-units=bracket}
\usetikzlibrary{arrows.meta, calc, quotes}
\tikzset{
Measure/.tip={Latex[] . Bar[sep=+0pt +-.5]},
pics/Measure/.style args={#1--#2}{code={
\path[Measure-Measure, midway, auto=right, sloped, draw, pic actions]
($(#1)!5pt!-90:(#2)$) -- node[style/.expand once=\tikzpictextoptions]{\tikzpictext}
($(#2)!5pt!90:(#1)$);}}}
\begin{document}
\begin{tikzpicture}[start angle=60, delta angle=60, thick]
\coordinate (O) at (0, 0);
\foreach[count=\i] \r/\t/\c in {
8.5//red,
8 //orange,
6 //yellow,
4 /\approx 0.5 \rho_0/green,
2 /\approx 2 \rho_0/blue!50,
0.001 /\numrange{3}{9}\rho_0/black%
} \draw[fill=\c] (O) -- (\pgfkeysvalueof{/tikz/start angle}:\r) coordinate (s-\i)
arc[radius=\r] node[at end, sloped, left]{$\t$} -- cycle;
%\foreach \pair/\t/\s in {
\pic["\qtyrange{9}{12}{\kilo\metre}"] {Measure = O--s-4};
\pic["\qtyrange{1} {2}{\kilo\metre}"] {Measure = s-4--s-2};
\pic["\qty{10}{\centi\metre}" {right, rotate=-90}, arrows={[scale length=.5]}] {Measure = s-2--s-1};
\end{tikzpicture}
\end{document}