Tikz의 \addmilestone이 올바른 지점에 이정표를 배치하지 않습니다.

Tikz의 \addmilestone이 올바른 지점에 이정표를 배치하지 않습니다.

여기 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무엇 이며 (즉, 귀하의 경우 아무것도 없음) 1부터 시작하는 카운터입니다. 따라서 예를 들어 1966-노드 가 호출 되므로 이정표를 예를 들어 에 넣을 수 있습니다 . 처음 두 개는 예시로 작성했지만 나머지는 직접 입력해도 됩니다. 어쨌든 텍스트를 어떻게 배치하고 싶은지 모르겠습니다.\timespantimespan={}\xi-1-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}

관련 정보