平均能量损失

平均能量损失

我想设置间隔的颜色

  • 14:00-15:00 至红色
  • 19:00-20:30 至绿
  • 20:30-21:30 至黄

如何改变它?

平均能量损失

\documentclass[border=12pt]{standalone}
\usepackage{pgfgantt}

\ganttset{group/.append style={transparent},
milestone/.append style={red},
progress label node anchor/.append style={text=red}}

\begin{document}
    \begin{ganttchart}[
     y unit title=0.5cm,
     y unit chart=0.7cm,
     vgrid,hgrid,
     title height=1,
     title label font=\bfseries\footnotesize,
     bar/.style={fill=blue},
     bar height=0.7,
     group right shift=0,
     group top shift=0.7,
     group height=.3,
     group peaks width={0.5},
     inline]{1}{24}
    \gantttitle{7}{2}
    \gantttitle{8}{2}
    \gantttitle{10}{2}
    \gantttitle{11}{2}
    \gantttitle{12}{2}
    \gantttitle{13}{2}
    \gantttitle{14}{2} 
    \gantttitle{15}{2}
    \gantttitle{19}{2}
    \gantttitle{20}{2}
    \gantttitle{21}{2} 
    \gantttitle{22}{2}\\
    \ganttgroup[inline=false]{Monday}{0}{0}
    \ganttbar[]{}{14}{15}% red
    \ganttbar[]{}{18}{20}% green
    \ganttbar[]{}{21}{22}\\% yellow
\end{ganttchart}
\end{document}

在此处输入图片描述

答案1

你可以[bar/.append style={fill=red}]这样使用:

    \ganttbar[bar/.append style={fill=red}]{}{14}{15}% red
    \ganttbar[bar/.append style={fill=green}]{}{18}{20}% green
    \ganttbar[bar/.append style={fill=yellow}]{}{21}{22}\\% yellow

在此处输入图片描述

梅威瑟:

\documentclass[border=12pt]{standalone}
\usepackage{pgfgantt}

\ganttset{group/.append style={transparent},
milestone/.append style={red},
progress label node anchor/.append style={text=red}}

\begin{document}
    \begin{ganttchart}[
     y unit title=0.5cm,
     y unit chart=0.7cm,
     vgrid,hgrid,
     title height=1,
     title label font=\bfseries\footnotesize,
     bar/.style={fill=blue},
     bar height=0.7,
     group right shift=0,
     group top shift=0.7,
     group height=.3,
     group peaks width={0.5},
     inline]{1}{24}
    \gantttitle{7}{2}
    \gantttitle{8}{2}
    \gantttitle{10}{2}
    \gantttitle{11}{2}
    \gantttitle{12}{2}
    \gantttitle{13}{2}
    \gantttitle{14}{2} 
    \gantttitle{15}{2}
    \gantttitle{19}{2}
    \gantttitle{20}{2}
    \gantttitle{21}{2} 
    \gantttitle{22}{2}\\
    \ganttgroup[inline=false]{Monday}{0}{0}
    \ganttbar[bar/.append style={fill=red}]{}{14}{15}% red
    \ganttbar[bar/.append style={fill=green}]{}{18}{20}% green
    \ganttbar[bar/.append style={fill=yellow}]{}{21}{22}\\% yellow
\end{ganttchart}
\end{document}

相关内容