有没有什么办法可以做出这样的图形?
我尝试过甘特图,但那不是我想要的。
\documentclass[tikz]{standalone}
%
% This is a direct copy of the codes in section 2.9 of the package
% documentation (See page 45) https://mirrors.tuna.tsinghua.edu.cn/CTAN/graphics/pgf/contrib/pgfgantt/pgfgantt.pdf
% except the color setting
\usepackage{pgfgantt}
\usepackage{xcolor}
\usepackage[utf8]{inputenc}
\definecolor{barblue}{RGB}{153,204,254}
\definecolor{groupblue}{RGB}{51,102,254}
\definecolor{linkred}{RGB}{165,0,33}
\begin{document}
\begin{ganttchart}[
y unit title=0.4cm,
y unit chart=0.5cm,
vgrid,
time slot format=isodate-yearmonth,
compress calendar,
title/.append style={draw=none, fill=barblue},
title label font=\sffamily\bfseries\color{white},
title label node/.append style={below=-1.6ex},
title left shift=.05,
title right shift=-.05,
title height=1,
bar/.append style={draw=none, fill=groupblue},
bar height=.6,
bar label font=\normalsize\color{black!50},
group right shift=0,
group top shift=.6,
group height=.3,
group peaks height=.2,
bar incomplete/.append style={fill=green}
]{2019-09}{2020-12}
\gantttitlecalendar{year}\\
\ganttbar[
progress=100,
bar progress label font=\small\color{barblue},
bar progress label node/.append style={right=4pt},
bar label font=\normalsize\color{barblue},
name=pp
]{}{2019-09}{2019-12} \\
\ganttset{progress label text={}, link/.style={black, -to}}
\ganttgroup{Virus}{2020-01}{2020-12} \\
\ganttbar[progress=4, name=T1A]{}{2020-01}{2020-06} \\
\ganttgroup{Objective 2}{2020-01}{2020-12} \\
\ganttbar[progress=15, name=T2A]{}{2020-01}{2020-09} \\
\ganttgroup{Objective 3}{2020-05}{2020-08} \\
\ganttbar[progress=0]{}{2020-05}{2020-08}
\ganttset{link/.style={green}}
\ganttlink[link mid=.4]{pp}{T1A}
\ganttlink[link mid=.159]{pp}{T2A}
\end{ganttchart}
\end{document}
答案1
你可以使用矩阵。除了填写文本之外,一切都很简单。我希望这不是必要的,那么就会有更多的时间来解释。
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{matrix,shapes.symbols,fit,calc}
\definecolor{mgreen}{RGB}{120,172,76}
\definecolor{mblue}{RGB}{81,123,189}
\definecolor{myellow}{RGB}{237,201,69}
\definecolor{mred}{RGB}{189,80,52}
\usepackage{eqparbox}
\newbox\eqnodebox
\tikzset{equal size/.style={execute at begin
node={\setbox\eqnodebox=\hbox\bgroup},
execute at end node={\egroup\eqmakebox[#1][\pgfkeysvalueof{/tikz/equal size align}]{\copy\eqnodebox}}},
equal size/.default=A,equal size align/.initial=l,
equal column/.style={column #1/.style={nodes={equal size=A#1}}},
msig/.style={signal,signal to=east,signal
from=nowhere,double=black,draw=white,rounded corners=1.5pt,
minimum height=1.2em,inner xsep=-1pt}}
\begin{document}
\begin{tikzpicture}[font=\sffamily,
%h/.style={minimum height={2pt+#1*1em-#1*1pt}}
]
\matrix[matrix of nodes,nodes in empty cells,
equal column/.list={1,...,7},
% fixed size/.list={4,5,6},
nodes={minimum height=2.2em,anchor=west},
column sep=1pt,row sep=1pt,
row 1/.style={nodes={fill=gray!60!black,text=white,node font=\small,
minimum height=3em}},
row 2/.style={nodes={fill=mgreen!60}},
row 3/.style={nodes={fill=mgreen!20}},
row 4/.style={nodes={fill=mgreen!50}},
row 5/.style={nodes={fill=myellow!60,minimum height=2.8em}},
row 6/.style={nodes={fill=mblue!60}},
row 7/.style={nodes={fill=mblue!80}},
row 8/.style={nodes={fill=mred!60,minimum height=3em}},
] (mat) {
Description & Disease & Preclinical &
\begin{tabular}{c} Phase\\ 1 \end{tabular} &
\begin{tabular}{c} Phase\\ 2 \end{tabular} &
\begin{tabular}{c} Phase\\ 3 \end{tabular} &
Marketed \\
& AML & & & & &\\
& MDS & & & & &\\
& NSCL& & & & & \\
& CLL& & & & & \\
& NSCLC& & & & & \\
& Nasopharyngel& & & & & \\
& Solid tumors& & & & & \\
};
\begin{scope}[pfit/.style n args={3}{fit={(mat-#1-1.north west)
(mat-#2-1.south east)},inner sep=0pt,
label={[anchor=west,node font=\small,align=left]west:{#3}}}]
\node[pfit={2}{4}{Sappa\\ pft pft pft},
fill=mgreen!90]{};
\node[pfit={5}{5}{Sappa\\ pft pft pft},anchor=center,
fill=myellow!90]{};
\node[pfit={6}{7}{Sappa\\ pft pft pft},anchor=center,
fill=mblue!90]{};
\node[pfit={8}{8}{Sappa\\ pft pft pft},anchor=center,
fill=mred!90]{};
\end{scope}
\begin{scope}[nodes=msig]
\node[fit=(mat-2-3.west) (mat-2-6.center),fill=mgreen]{};
\node[fit=(mat-3-3.west) (mat-3-5.east),fill=mgreen]{};
\node[fit={(mat-4-3.west) ($(mat-4-5.west)!0.8!(mat-4-5.east)$)},fill=mgreen]{};
\node[fit={(mat-5-3.west) ($(mat-5-5.west)!0.6!(mat-5-5.east)$)},fill=myellow]{};
\node[fit={(mat-6-3.west) ($(mat-6-5.west)!0.7!(mat-6-5.east)$)},fill=mblue]{};
\node[fit={(mat-7-3.west) ($(mat-7-5.west)!0.2!(mat-7-5.east)$)},fill=mblue]{};
\node[fit={(mat-8-3.west) ($(mat-8-4.west)!0.6!(mat-8-4.east)$)},fill=red]{};
\end{scope}
\end{tikzpicture}
\end{document}