![平均能量损失](https://linux22.com/image/352373/%E5%B9%B3%E5%9D%87%E8%83%BD%E9%87%8F%E6%8D%9F%E5%A4%B1.png)
我想设置间隔的颜色
- 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}