I have essentially survival-type data, and I am trying to show the survival duration for each of four groups. I have end-point data, and I need to go backwards from the last date to show when each cohort entered the data. The snippet of code below contains the entire set of information I need in my chart, rather than being a toy example.
I thought a Gantt chart might be the best format - the 4 years across the top, and then add in the four cohorts. I am damned if I can do this. Note that I am working in a dark mode in my editor, to save my eyes, so the images are shown light on dark.
My latest attempt:
\documentclass[article]
\begin{document}
\begin{ganttchart}[
expand chart =\textwidth,
y unit title = .5 cm,
y unit chart = .5 cm,
hgrid
]{1}{4}
\gantttitle{Possible year of school exit}{4}\\
\gantttitle{2009}{1}
\gantttitle{2010}{1}
\gantttitle{2011}{1}
\gantttitle{2012}{1} \\
\ganttbar{}{15-year-olds}{4} \\
\ganttbar{}{16-year-olds}{3,4} \\
\ganttbar{}{17-year-olds}{2,3,4} \\
\ganttbar{}{15-year-olds}{1,2,3,4} \\
\end{ganttchart}
\end{document}
The width is correctly across the page, but no bars are showing. It also doesn't work when I try to put the years into the \ganttbar
instead of 1, 2, 3, and/or 4.
Another problem is that the text, that is showing, is too high for the title box (I would like to make the box larger vertically as the text is the correct font size).
The chart is too wide, so I tried to change the width to how I specify when I bring in PDF images, and that went bad as well:
expand chart =.8
gave
I seem to have some horizontal lines, but neither contain any text. The years are also backwards.
What do I need to do to modify the code so that I can get my nice little Gantt chart? I also tried to put it into a figure environment so that I could add a label and caption (which I need) and that went badly as well. I have the manual, and can't see what I am doing wrong.
Edit 1: update
I have changed to this code, but I still can't get the bars to show, and the height of the cells is still too small relative to the font size.
\begin{figure}
\begin{ganttchart}[
x unit = 1.5cm,
y unit title = .5 cm,
y unit chart = .5 cm,
vgrid
]{1}{4}
\gantttitle{Possible year of school exit}{4}\\
\gantttitle{2009}{1}
\gantttitle{2010}{1}
\gantttitle{2011}{1}
\gantttitle{2012}{1} \\
\ganttbar{}{15-year-olds}{4}{4} \\
\ganttbar{}{16-year-olds}{3}{4} \\
\ganttbar{}{17-year-olds}{2}{4} \\
\ganttbar{}{15-year-olds}{1}{4} \\
\end{ganttchart}
\end{figure}
Which gives me: