![仅标记特定切片 pgf-pie](https://linux22.com/image/460702/%E4%BB%85%E6%A0%87%E8%AE%B0%E7%89%B9%E5%AE%9A%E5%88%87%E7%89%87%20pgf-pie.png)
我正在尝试创建一个饼图来展示 SpaceX 在其控制的轨道资产数量方面占据主导地位。
根据我的数据,我生成了以下内容:
\documentclass[a4paper]{article}
\usepackage{pgfplots}
\usepackage{pgf-pie}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\begin{document}
\begin{figure}
\begin{tikzpicture}
\pie [sum=100, scale font, text=pin]
{31.95/SpaceX Seattle, 4.36/One Web, 3.18/Planet Labs, 3.04/United States Air Force, 2.27/Main Space Forces Directorate, 1.67/Main Space Forces Directorate, 1.57/Russian Space Forces, 1.54/Upravleniye Nachalnika Kosmicheskikh Sredstv, 1.51/Swarm Technologies, 1.33/NASA Goddard Space Flight Center, 1.32/Soviet Navy, 1.23/General Armaments Dept. of the PLA, 1.14/Spire, 1.06/Iridium Inc., 1/Russian Military Space Forces, 0.95/Indian Space Research Organization, 0.88/OKB-10 (Reshetnev), 0.88/China Aerospace Sci/Tech Corp, 0.87/Globalstar LLC, 0.83/National Reconnaissance Office, 0.81/Proto-Vozdhusnoy Oborony, 0.73/GLONASS Information-Analytic Center, 0.73/China National Space Administration, 0.73/Chang Guang Satellite Technology Ltd, 0.72/United States Navy, 0.68/European Space Agency, 0.66/Naval Research Lab, 0.62/Orbcomm Inc., 0.58/International Telecommunications Satellite Organization, 0.54/Ministry of Comms. Union Radio Comms., 0.52/National Space Research Center, 30.1/Small Operators (<50 sats)};
\end{tikzpicture}
\caption{Distribution of control over space-borne assets}
\label{fig:controlpie}
\end{figure}
\end{document}
这就造成了这一混乱局面:
为了使这个更清晰,我只想标记一些有趣的部分。即 SpaceX、One Web、Planet Labs、美国空军、Iridium 和 ESA。为此,我尝试过:
- 使用图例——太长了
- 对于我不想标记的标签,请将其留空 - 它只会将值放在引脚上
理想情况下,我还希望能够隐藏除 SpaceX 和小型运营商之外的所有运营商的内部百分比,但这可能需要一个单独的问题
答案1
以下答案使用轮图包,是我写的。
使用 wheelchart 包 2.0 版本回答:
使用键 和 指定切片 1、2、3、4、14 和 26data
的和。lines
data{1,2,3,4,14,26}
lines{1,2,3,4,14,26}
切片的颜色通过带有键的列表来指定slices style{list}
。
切片 1 和 32 的键wheel data
由 指定wheel data{1,32}
。此处,\WCperc
表示百分比。
\documentclass[border=6pt]{standalone}
\usepackage{wheelchart}
\begin{document}
\begin{tikzpicture}
\wheelchart[
data=,
data{1,2,3,4,14,26}=\WCvarB,
lines{1,2,3,4,14,26}=1,
perc precision=2,
pie,
slices style{list}={blue,green,yellow,red},
wheel data{1,32}=\WCperc
]{%
31.95/SpaceX Seattle,
4.36/One Web,
3.18/Planet Labs,
3.04/United States Air Force,
2.27/Main Space Forces Directorate,
1.67/Main Space Forces Directorate,
1.57/Russian Space Forces,
1.54/Upravleniye Nachalnika Kosmicheskikh Sredstv,
1.51/Swarm Technologies,
1.33/NASA Goddard Space Flight Center,
1.32/Soviet Navy,
1.23/General Armaments Dept. of the PLA,
1.14/Spire,
1.06/Iridium Inc.,
1/Russian Military Space Forces,
0.95/Indian Space Research Organization,
0.88/OKB-10 (Reshetnev),
0.88/China Aerospace Sci/Tech Corp,
0.87/Globalstar LLC,
0.83/National Reconnaissance Office,
0.81/Proto-Vozdhusnoy Oborony,
0.73/GLONASS Information-Analytic Center,
0.73/China National Space Administration,
0.73/Chang Guang Satellite Technology Ltd,
0.72/United States Navy,
0.68/European Space Agency,
0.66/Naval Research Lab,
0.62/Orbcomm Inc.,
0.58/International Telecommunications Satellite Organization,
0.54/Ministry of Comms. Union Radio Comms.,
0.52/National Space Research Center,
30.1/Small Operators ($<50$ sats)%
}
\end{tikzpicture}
\end{document}
使用 wheelchart 包 1.0 版本回答:
\WCtest
定义一个命令来指定切片 1、2、3、4、14 和 26data
的和。这里,给出切片的当前编号。lines
\WCcount
类似地,wheel data
针对切片 1 和 32 进行了指定。
\documentclass[border=6pt]{standalone}
\usepackage{xcolor}
\usepackage{wheelchart}
\begin{document}
\begin{tikzpicture}
\def\WCtest#1#2{ifthenelse(\WCcount==1||\WCcount==2||\WCcount==3||\WCcount==4||\WCcount==14||\WCcount==26,#1,#2)}
\wheelchart[
data={\pgfmathparse{\WCtest{"\WCvarB"}{}}\pgfmathresult},
lines={\WCtest{1}{0}},
perc precision=2,
pie,
slices style={/utils/exec={\pgfmathsetmacro{\WCcolornumber}{int(Mod({\WCcount-1},4)+1)*60+400}\definecolor{WCcolor}{wave}{\WCcolornumber}},WCcolor},
wheel data={\pgfmathparse{ifthenelse(\WCcount==1||\WCcount==32,"\WCperc",)}\pgfmathresult}
]
{31.95/SpaceX Seattle, 4.36/One Web, 3.18/Planet Labs, 3.04/United States Air Force, 2.27/Main Space Forces Directorate, 1.67/Main Space Forces Directorate, 1.57/Russian Space Forces, 1.54/Upravleniye Nachalnika Kosmicheskikh Sredstv, 1.51/Swarm Technologies, 1.33/NASA Goddard Space Flight Center, 1.32/Soviet Navy, 1.23/General Armaments Dept. of the PLA, 1.14/Spire, 1.06/Iridium Inc., 1/Russian Military Space Forces, 0.95/Indian Space Research Organization, 0.88/OKB-10 (Reshetnev), 0.88/China Aerospace Sci/Tech Corp, 0.87/Globalstar LLC, 0.83/National Reconnaissance Office, 0.81/Proto-Vozdhusnoy Oborony, 0.73/GLONASS Information-Analytic Center, 0.73/China National Space Administration, 0.73/Chang Guang Satellite Technology Ltd, 0.72/United States Navy, 0.68/European Space Agency, 0.66/Naval Research Lab, 0.62/Orbcomm Inc., 0.58/International Telecommunications Satellite Organization, 0.54/Ministry of Comms. Union Radio Comms., 0.52/National Space Research Center, 30.1/Small Operators ($<50$ sats)}
\end{tikzpicture}
\end{document}