\addmilestone в Tikz не размещает веху в правильной точке

\addmilestone в Tikz не размещает веху в правильной точке

Вот 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. Следовательно, узел 1966, например, называется -1, поэтому вы можете поместить свою веху в eg -1.south. Я сделал первые два в качестве примера, но вы можете заполнить остальные самостоятельно. Я не знаю, как вы хотели бы разместить текст в любом случае:

вывод кода

Вы могли заметить, что круг для вехи не точно по центру под годом. Причиной этого является явный пробел в тексте узла, как вы можете видеть из строк98 и 102 вtikzlibrarytimeline.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}

Связанный контент