
這是一個 MWE。\addmilestones
MWE 中註解掉的內容就是問題所在。我需要的實際日期顯示在每個命令的末尾\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 開始的計數器。為-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}