pgfgantt-在甘特图顶部添加数字线

pgfgantt-在甘特图顶部添加数字线

如何在甘特图顶部添加数字线,如下图所示?MWE 补充道。

\documentclass[ ]{article}
\usepackage{pgfgantt}
\definecolor{foobarblue}{RGB}{0,153,255}
\newganttchartelement{foobar}{
foobar/.style={
shape=rectangle,
inner sep=0pt,
draw=foobarblue!50!black,
very thick,
fill=white}
}
\begin{document}
\begin{ganttchart}[
vgrid,
inline,
progress label text=\relax,
]{1}{15}
\ganttfoobar{Bar 1}{1}{3} \\
\ganttfoobar{Bar 2}{3}{7} \\
\ganttfoobar{Bar 3}{9}{12}
\end{ganttchart}
\end{document}

在此处输入图片描述

答案1

你可以使用常规的 Ti环境内的 Z 命令ganttchart。请注意,默认情况下 x 轴的基本单位为 0.5 厘米:

\documentclass[ ]{article}
\usepackage{pgfgantt}

\definecolor{foobarblue}{RGB}{0,153,255}
\newganttchartelement{foobar}{
    foobar/.style={
        shape=rectangle,
        inner sep=0pt,
        draw=foobarblue!50!black,
        very thick,
        fill=white
    }
}

\begin{document}

\begin{ganttchart}[
    vgrid,
    inline,
    progress label text=\relax,
]{1}{15}
\ganttfoobar{Bar 1}{1}{3} \\
\ganttfoobar{Bar 2}{3}{7} \\
\ganttfoobar{Bar 3}{9}{12}

\begin{scope}[yshift=0.33cm]
    \draw[-stealth] (0,0) -- (7.5,0);
    \draw ([yshift=-3pt]0,0) -- ++([yshift=6pt]0,0) node[above] {0};
    \draw ([yshift=-3pt]1,0) -- ++([yshift=6pt]0,0) node[above] {$x$};
    \draw ([yshift=-3pt]4,0) -- ++([yshift=6pt]0,0) node[above] {$y$};
\end{scope}
\end{ganttchart}

\end{document}

在此处输入图片描述

相关内容