这是 MWE。MWE\addmilestones
中注释掉的就是问题所在。我需要的实际日期显示在每个\addmilestone
命令的末尾。此外,气泡的颜色应该是与气泡大小相称的不同深浅的红色。小气泡 = 浅红色,最大气泡 = 血红色。
该timeline
图书馆位于https://github.com/cfiandra/timeline
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{timeline}
\begin{document}
\begin{tikzpicture}[timespan={}]
% timespan={Day} -> now we have days as reference
% timespan={} -> no label is displayed for the timespan
% default timespan is 'Week'
\timeline[custom interval=true]{1966, 1971, 1979, 1980, 1981,1986,1996,2001,2006,2011,2016}
% \timeline[custom interval=true]{3,...,9} -> i.e., from Day 3 to Day 9
% \timeline{8} -> i.e., from Week 1 to Week 8
% put here the phases
\begin{phases}
\initialphase{involvement degree=0cm,phase color=black}
\phase{between week=1 and 1 in 0.5,involvement degree=1.65cm}
\phase{between week=2 and 3 in 0.5,involvement degree=3.5cm}
\phase{between week=3 and 4 in 0.5,involvement degree=0cm}
\phase{between week=4 and 5 in 0.5,involvement degree=0cm}
\phase{between week=5 and 6 in 0.5,involvement degree=0}
\phase{between week=5 and 6 in 0.5,involvement degree=2.5cm} Guerilla
\phase{between week=6 and 7 in 0.5,involvement degree=1.9cm}
\phase{between week=7 and 8 in 0.5,involvement degree=3cm}
\phase{between week=8 and 9 in 0.5,involvement degree =1.7cm}
\end{phases}
% put here the milestones
\addmilestone{at=phase-0.270,direction=270:2cm,text={Obote/UPC win First Multiparty elections},text options={below}} %1962
\addmilestone{at=phase-1.110,direction=90:2cm,text={Obote attacks President Mutesa palace},text options={above}}
\addmilestone{at=phase-2.110,direction=90:1.5cm,text={Idi Amin's Reign of Terror},text options={above}}
\addmilestone{at=phase-6.270,direction=270:1cm,text={Museveni Bush War},text options={below}}
\addmilestone{at=phase-7.110,direction=110:1.5cm,text={Northern Uganda War I},text options={above}}
\addmilestone{at=phase-8.90,direction=90:1.5cm,text={Northern Uganda War II},text options={above}}
\addmilestone{at=phase-9.60,direction=60:1.5cm,text={Northern Uganda War III},text options={above}}
%These are the problematic milestones I cannot get them placed at individual point dates, eg. 1966, 1971 etc...
%\addmilestone{at=phase-8.250,direction=240:1.5cm,text={Obote abrogates Constitution },text options={below}} % 1966
%\addmilestone{at=phase-8.250,direction=240:1.5cm,text={Idi Amin overthrows Obote },text options={below}} % 1971
%\addmilestone{at=phase-8.250,direction=240:1.5cm,text={Multiparty elections. Obote wins },text options={below}} % 1980
%\addmilestone{at=phase-6.170,direction=170:1.5cm,text={Museveni starts Bush war},text options={below}} % 1981
%\addmilestone{at=phase-6.170,direction=170:1.5cm,text={Okellos overthrow Obote II},text options={below}} 1985
%\addmilestone{at=phase-6.170,direction=170:1.5cm,text={Museveni seizes power from Okellos},text options={below}} 1986
%\addmilestone{at=phase-8.250,direction=240:1.5cm,text={``No party'' elections. Museveni wins },text options={below}} % 1996
%\addmilestone{at=phase-8.250,direction=240:1.5cm,text={``No party'' elections, Museveni wins },text options={below}} % 2001
%\addmilestone{at=phase-8.250,direction=240:1.5cm,text={Multiparty elections, Museveni wins },text options={below}} % 2006
\end{tikzpicture}
\end{document}
答案1
不确定我是否理解正确,但保存年份的节点被命名为\timespan-\xi
,其中\timespan
是您在 中定义的内容timespan={}
(即在您的情况下为空),并且\xi
是从 1 开始的计数器。因此,例如 1966 节点被称为-1
,因此您可以将里程碑放在-1.south
。我以前两个为例,但您可以自己填写其余部分。无论如何,我不知道您想如何放置文本:
您可能会注意到里程碑的圆圈并不完全位于年份的中心。造成这种情况的原因是节点文本中有一个明确的空格,正如您从以下几行中看到的那样98 和 102tikzlibrarytimeline.code.tex
添加draw=white
到节点选项演示了这一点:
但是,你可以修补\timeline
宏以删除空格,使用
\usepackage{xpatch}
\xpatchcmd{\timeline}{\timespan\ \x}{\x}{}{}
对于颜色部分我没有答案。
应用补丁后的完整代码:
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{timeline}
\usepackage{xpatch}
\xpatchcmd{\timeline}{\timespan\ \x}{\x}{}{}
\begin{document}
\begin{tikzpicture}[timespan={}]
% timespan={Day} -> now we have days as reference
% timespan={} -> no label is displayed for the timespan
% default timespan is 'Week'
\timeline[custom interval=true]{1966, 1971, 1979, 1980, 1981,1986,1996,2001,2006,2011,2016}
% \timeline[custom interval=true]{3,...,9} -> i.e., from Day 3 to Day 9
% \timeline{8} -> i.e., from Week 1 to Week 8
% put here the phases
\begin{phases}
\initialphase{involvement degree=0cm,phase color=black}
\phase{between week=1 and 1 in 0.5,involvement degree=1.65cm}
\phase{between week=2 and 3 in 0.5,involvement degree=3.5cm}
\phase{between week=3 and 4 in 0.5,involvement degree=0cm}
\phase{between week=4 and 5 in 0.5,involvement degree=0cm}
\phase{between week=5 and 6 in 0.5,involvement degree=0}
\phase{between week=5 and 6 in 0.5,involvement degree=2.5cm}
\phase{between week=6 and 7 in 0.5,involvement degree=1.9cm}
\phase{between week=7 and 8 in 0.5,involvement degree=3cm}
\phase{between week=8 and 9 in 0.5,involvement degree =1.7cm}
\end{phases}
% put here the milestones
\addmilestone{at=phase-0.270,direction=270:2cm,text={Obote/UPC win First Multiparty elections},text options={below}} %1962
\addmilestone{at=phase-1.110,direction=90:2cm,text={Obote attacks President Mutesa palace},text options={above}}
\addmilestone{at=phase-2.110,direction=90:1.5cm,text={Idi Amin's Reign of Terror},text options={above}}
\addmilestone{at=phase-6.270,direction=270:1cm,text={Museveni Bush War},text options={below}}
\addmilestone{at=phase-7.110,direction=110:1.5cm,text={Northern Uganda War I},text options={above}}
\addmilestone{at=phase-8.90,direction=90:1.5cm,text={Northern Uganda War II},text options={above}}
\addmilestone{at=phase-9.60,direction=60:1.5cm,text={Northern Uganda War III},text options={above}}
%These are the problematic milestones I cannot get them placed at individual point dates, eg. 1966, 1971 etc...
\addmilestone{at=-1.south,direction=240:1.5cm,text={Obote abrogates Constitution },text options={below}} % 1966
\addmilestone{at=-2.south,direction=270:1.cm,text={Idi Amin overthrows Obote },text options={below}} % 1971
%\addmilestone{at=phase-8.250,direction=240:1.5cm,text={Multiparty elections. Obote wins },text options={below}} % 1980
%\addmilestone{at=phase-6.170,direction=170:1.5cm,text={Museveni starts Bush war},text options={below}} % 1981
%\addmilestone{at=phase-6.170,direction=170:1.5cm,text={Okellos overthrow Obote II},text options={below}} 1985
%\addmilestone{at=phase-6.170,direction=170:1.5cm,text={Museveni seizes power from Okellos},text options={below}} 1986
%\addmilestone{at=phase-8.250,direction=240:1.5cm,text={``No party'' elections. Museveni wins },text options={below}} % 1996
%\addmilestone{at=phase-8.250,direction=240:1.5cm,text={``No party'' elections, Museveni wins },text options={below}} % 2001
%\addmilestone{at=phase-8.250,direction=240:1.5cm,text={Multiparty elections, Museveni wins },text options={below}} % 2006
\end{tikzpicture}
\end{document}