Latex绘制甘特图

一、甘特图源代码

\begin{figure}[thp!]
\centering
\begin{ganttchart}[%Specs
    x unit=0.55cm,
    y unit title=0.6cm,
    y unit chart=0.6cm,
    % vgrid,hgrid,
    hgrid={
    *3{black!1, line width=.0pt},*1{draw=black!60, line width=.55pt}, 
    *2{black!1, line width=.0pt},*1{draw=black!60, line width=.55pt},
    *2{black!1, line width=.0pt},*1{draw=black!60, line width=.55pt},
    *3{black!1, line width=.0pt},*1{draw=black!60, line width=.55pt},
    },
    vgrid={*3{black!1, line width=.0pt},*1{draw=black!60, dash pattern=on 3.5pt off 4.5pt, line width=.35pt}},
%    title/.style={fill=teal, draw=none},
%    title label font=\heiti\color{white}\bfseries,
    title height=1,
    title label font=\sffamily\footnotesize,
    bar/.style={fill=light_blue},
    % bar/.append style={fill=light_green},
    % bar incomplete/.append style={fill=origin_orange},
    bar label font=\sffamily\footnotesize,
    bar right shift=0,
    bar left shift=0,
    bar height=0.35,
    bar top shift=0.2,
%    progress label text={},
    % bar progress label font=\small\heiti\footnotesize,
    % group progress label font=\small\heiti\footnotesize,
    % group progress label font=\small\heiti\calibri\footnotesize,
    % group progress label node/.append style={below=3pt}
    group label font=\small\sffamily\bfseries,
    group right shift=0,
    group left shift=0,
    group top shift=0.2,
    group height=.5,
    group peaks width={0.3},
    group peaks tip position=0,
    group peaks height=.25,
    ]{1}{16}
    %labels
    \gantttitle[title/.style={fill=cyan, draw=none}]{项目年度研究计划}{16}\\
    \gantttitle[title/.style={fill=light_green, draw=none}]{2024年度}{4}                 % title 1
    \gantttitle[title/.style={fill=light_red, draw=none}]{2025年度}{4} 
    \gantttitle[title/.style={fill=light_purple, draw=none}]{2026年度}{4} 
    \gantttitle[title/.style={fill=light_yellow, draw=none}]{2027年度}{4} \\              
    % Setting group if any
    \ganttgroup[group/.append style={fill=deep_green}, 
    group incomplete/.append style={fill=origin_orange},
    progress=7.5]{计划A}{1}{4}\\ 
    \ganttbar[bar/.style={fill=deep_green}, bar incomplete/.append style={fill=light_blue}, progress=30]{计划A - 1}{1}{1}\\
    \ganttbar{计划A - 2}{2}{4}\\

    \ganttgroup{计划B}{5}{8} \\ 
    \ganttbar{计划B - 1}{5}{6} \\
    \ganttbar{计划B - 2}{7}{8} \\    
    
    \ganttgroup{计划C}{9}{12} \\ 
    \ganttbar{计划C - 1}{9}{10} \\
    \ganttbar{计划C - 2}{10}{12} \\    

    \ganttgroup{计划D}{13}{16} \\ 
    \ganttbar{计划D - 1}{13}{13} \\ 
    \ganttbar{计划D - 2}{14}{14} \\ 
    \ganttbar{计划D - 3}{14}{16}
\end{ganttchart}
\caption{甘特图}
\label{fig:gant}
\end{figure}

二、效果图

你可能感兴趣的:(甘特图)