13

I'm making a timeline for my thesis proposal using the pgfgantt package, and I'd like for each aim to use different coloured bars. Here's the current version.

](![pdfgantt aims

\documentclass[12pt]{article}
\usepackage[margin=1.0in]{geometry}
\usepackage{pgfgantt}
\begin{document}

\begin{ganttchart}[
    y unit title=0.5cm,
    y unit chart=0.6cm,
    time slot format=isodate-yearmonth,
    compress calendar,
    title/.append style={shape=rectangle, fill=black!10},
    title height=1,
    bar/.append style={fill=green!90},
    bar height=.6,
    bar label font=\normalsize\color{black!50},
    group top shift=.6,
    group height=.3,
    group peaks height=.2,
    bar incomplete/.append style={fill=green!40}
  ]{2015-05}{2017-06}
  \gantttitlecalendar{year} \\
  \gantttitlecalendar{month} \\
  \ganttset{progress label text={}} % this suppresses percentage done labels
  \ganttgroup{Aim 1: Phenotypes}{2015-06}{2015-12} \\
    \ganttbar[progress=00, name=rclone]{R cloning}{2015-06}{2015-07} \\
    \ganttlinkedbar[progress=00, name=rflr]{R fluorescence}{2015-07}{2015-09} \\
    \ganttlinkedbar[progress=00, name=rqpcr]{R RT-qPCR}{2015-10}{2015-11} \\
    \ganttbar[progress=00, name=kover]{KO verification}{2015-06}{2015-07} \\
    \ganttlinkedbar[progress=00, name=kogro]{KO growth}{2015-08}{2015-09} \\
    \ganttbar[progress=00, name=koflr]{KO fluorescence}{2015-08}{2015-09} \\
    \ganttlinkedbar[progress=00, name=koo2]{KO O2 evolution}{2015-10}{2015-11} \\
  \ganttgroup{Aim 2: Expression}{2015-06}{2017-02} \\
    \ganttbar[progress=00, name=oeclone]{Clone OEs}{2016-01}{2016-03} \\
    \ganttbar[progress=00, name=rnagrow]{Grow KOs + OEs}{2016-04}{2016-06} \\
    \ganttlinkedbar[progress=00, name=rnaprep]{RNA library prep}{2016-07}{2016-09} \\
    \ganttbar[progress=00, name=rnadev]{Develop analysis}{2015-06}{2015-07} \\
    \ganttbar[progress=00, name=rnaanal]{Analyze reads}{2016-12}{2017-02} \\
  \ganttgroup{Aim 3: Binding sites}{2016-01}{2017-05} \\
    \ganttbar[progress=00, name=chipgrow]{Grow KOs + OEs}{2016-04}{2016-06} \\
    \ganttlinkedbar[progress=00, name=chipprep]{ChIP library prep}{2016-08}{2016-12} \\
    \ganttbar[progress=00, name=chipdev]{Develop analysis}{2016-01}{2016-02} \\
    \ganttbar[progress=00, name=chipanal]{Analyze reads}{2017-03}{2017-05}
  % misc links
  \ganttset{progress label text={}}
  \ganttlink[]{oeclone}{rnagrow}
  \ganttlink[link mid=0.082]{oeclone}{chipgrow}
  \ganttlink[]{rnaprep}{rnaanal}
  \ganttlink[link mid=0.25]{kover}{koflr}
  \ganttlink[link mid=0.75]{kogro}{koo2}
  \ganttlink[link mid=0.55]{koo2}{oeclone}
  \ganttlink[link mid=0.55]{rqpcr}{oeclone}
  \ganttlink[]{chipprep}{chipanal}
  \ganttlink[link mid=0.938]{rnadev}{rnaanal}
  \ganttlink[link mid=0.915]{chipdev}{chipanal}
\end{ganttchart}

\end{document}

How can I make Aim 1 green, Aim 2 red, and Aim 3 blue for example?

1
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format.
    – Symbol 1
    Apr 8, 2015 at 4:57

1 Answer 1

10

Add \ganttsets in the middle like:

\ganttset{bar incomplete/.append style={fill=red!40},
    group/.append style={draw=black, fill=red},}

Code:

\documentclass[12pt]{article}
\usepackage[margin=1.0in]{geometry}
\usepackage{pgfgantt}
\begin{document}

\begin{ganttchart}[
    y unit title=0.5cm,
    y unit chart=0.6cm,
    time slot format=isodate-yearmonth,
    compress calendar,
    title/.append style={shape=rectangle, fill=black!10},
    title height=1,
    bar/.append style={fill=green!90},
    bar height=.6,
    bar label font=\normalsize\color{black!50},
    group top shift=.6,
    group height=.3,
    group peaks height=.2,
    bar incomplete/.append style={fill=green!40}
  ]{2015-05}{2017-06}
  \gantttitlecalendar{year} \\
  \gantttitlecalendar{month} \\
  \ganttset{progress label text={},
       bar incomplete/.append style={fill=green!40},
       group/.append style={draw=black, fill=green},} % this suppresses percentage done labels
  \ganttgroup{Aim 1: Phenotypes}{2015-06}{2015-12} \\
    \ganttbar[progress=00, name=rclone]{R cloning}{2015-06}{2015-07} \\
    \ganttlinkedbar[progress=00, name=rflr]{R fluorescence}{2015-07}{2015-09} \\
    \ganttlinkedbar[progress=00, name=rqpcr]{R RT-qPCR}{2015-10}{2015-11} \\
    \ganttbar[progress=00, name=kover]{KO verification}{2015-06}{2015-07} \\
    \ganttlinkedbar[progress=00, name=kogro]{KO growth}{2015-08}{2015-09} \\
    \ganttbar[progress=00, name=koflr]{KO fluorescence}{2015-08}{2015-09} \\
    \ganttlinkedbar[progress=00, name=koo2]{KO O2 evolution}{2015-10}{2015-11} \\
  \ganttset{bar incomplete/.append style={fill=red!40},
    group/.append style={draw=black, fill=red},}
  \ganttgroup{Aim 2: Expression}{2015-06}{2017-02} \\
    \ganttbar[progress=00, name=oeclone]{Clone OEs}{2016-01}{2016-03} \\
    \ganttbar[progress=00, name=rnagrow]{Grow KOs + OEs}{2016-04}{2016-06} \\
    \ganttlinkedbar[progress=00, name=rnaprep]{RNA library prep}{2016-07}{2016-09} \\
    \ganttbar[progress=00, name=rnadev]{Develop analysis}{2015-06}{2015-07} \\
    \ganttbar[progress=00, name=rnaanal]{Analyze reads}{2016-12}{2017-02} \\
  \ganttset{bar incomplete/.append style={fill=blue!40},
  group/.append style={draw=black, fill=blue},}
  \ganttgroup{Aim 3: Binding sites}{2016-01}{2017-05} \\
    \ganttbar[progress=00, name=chipgrow]{Grow KOs + OEs}{2016-04}{2016-06} \\
    \ganttlinkedbar[progress=00, name=chipprep]{ChIP library prep}{2016-08}{2016-12} \\
    \ganttbar[progress=00, name=chipdev]{Develop analysis}{2016-01}{2016-02} \\
    \ganttbar[progress=00, name=chipanal]{Analyze reads}{2017-03}{2017-05}
  % misc links
  \ganttset{progress label text={}}
  \ganttlink[]{oeclone}{rnagrow}
  \ganttlink[link mid=0.082]{oeclone}{chipgrow}
  \ganttlink[]{rnaprep}{rnaanal}
  \ganttlink[link mid=0.25]{kover}{koflr}
  \ganttlink[link mid=0.75]{kogro}{koo2}
  \ganttlink[link mid=0.55]{koo2}{oeclone}
  \ganttlink[link mid=0.55]{rqpcr}{oeclone}
  \ganttlink[]{chipprep}{chipanal}
  \ganttlink[link mid=0.938]{rnadev}{rnaanal}
  \ganttlink[link mid=0.915]{chipdev}{chipanal}
\end{ganttchart}

\end{document}

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .