
관련하여 급하게 질문이 있습니다.pgfgantt패키지:
논문의 경우 다음과 같은 그래프를 그릴 수 있어야 합니다.
pgfgantt
그러나 지금까지 본 지침으로는 어떻게 해야 할지 알 수 없는 것 같습니다. 지금까지 나는 다음과 같은 것을 얻었습니다.
내 코드는 다음과 같습니다.
\begin{ganttchart}[
inline, % puts the label inside the bar
hgrid,
vgrid,
bar height=1
]{1}{10}
% P3
\ganttgroup[inline=false,group/.style={draw=none, fill=none}]{P3}{2,0}{25,0}
\ganttbar[bar/.append style={fill=green}]{$T1$}{1}{2}
\ganttbar{}{3}{4}
\ganttbar[bar/.append style={fill=orange}]{$T3$}{5}{7}
\ganttbar{}{8}{9}
\ganttbar[bar/.append style={fill=cyan}]{$T5$}{10}{10}
\\
% P2
\ganttgroup[inline=false,group/.style={draw=none, fill=none}]{P2}{2,0}{25,0}
\ganttbar[bar/.append style={fill=green}]{$T1$}{1}{2}
\ganttbar{}{3}{4}
\ganttbar{}{3}{4}
\ganttbar{}{5}{7}
\ganttbar[bar/.append style={fill=yellow}]{$T4$}{8}{9}
\ganttbar[bar/.append style={fill=cyan}]{$T5$}{10}{10}
\\
% P1
\ganttgroup[inline=false,group/.style={draw=none, fill=none}]{P1}{2,0}{25,0}
\ganttbar{}{1}{4}
\ganttbar[bar/.append style={fill=orange}]{$T3$}{5}{7}
\ganttbar[bar/.append style={fill=yellow}]{$T4$}{8}{9}
\ganttbar{}{10}{10}
%
\end{ganttchart}
그래서 내 질문은: 다중 프로세서(P_x)에서 작업을 만들고 서로 속한 것처럼 보이도록 하려면 어떻게 해야 합니까(검은색 테두리 제거, 단 하나의 표기법 등)?
답변1
내가 대안을 제시하는 것을 꺼리지 않기를 바랍니다. 패키지 에 이미 익숙하다면 pgfplots
이 패키지를 대신 사용하는 것이 코드를 pgfgantt
너무 많이 다루지 않고도 쉬운 옵션일 수 있습니다 pgfgantt
.
area plot
이는 매뉴얼 의 4.5.10절에 설명된 를 사용한 예입니다 pgflots
.
는 \addplot
다음 순서로 좌표를 지정합니다.{(south west) (north west) (north east) (south east)}
환경 에 대한 일반적인 설정이 axis
약간 증가했습니다(보통 에서 발생한다고 생각함 pgfplots
). 특정 설정에 대해 궁금한 점이 있으면 댓글로 답변해 드리겠습니다.
결과:
암호:
\documentclass{standalone}
\usepackage{pgfplots}
\usetikzlibrary{intersections}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
font=\footnotesize,
ytick style={draw=none},
xtick style={draw=none},
unit vector ratio*=1 1 1,
axis lines = middle,
enlarge x limits = {value=.1,upper},
enlarge y limits = {value=.05,upper},
ylabel={processors},
xlabel={time},
ylabel near ticks,
xlabel near ticks,
const plot,
stack plots=false,
area style,
ytick={1,...,11},
yticklabels={},
xtick={1,...,4},
extra y ticks={3,5,6,8,10,11},
extra y tick style={yticklabel={$P_{\pgfmathprintnumber{\tick}}$}}
]
\addplot[fill=yellow] coordinates {(0,0) (0,3) (3,3) (3,0) } node at (current path bounding box.center) {T4};
\addplot[fill=orange] coordinates {(0,3) (0,5) (2,5) (2,3)} node at (current path bounding box.center) {T3};
\addplot[fill=red!20] coordinates {(2,3) (2,5) (3,5) (3,3)} node at (current path bounding box.center) {T7};
\addplot[fill=gray] coordinates {(3,0) (3,8) (4,8) (4,0)} node at (current path bounding box.center) {T9};
\addplot[fill=teal] coordinates {(0,5) (0,11) (1,11) (1,5)} node at (current path bounding box.center) {T5};
\addplot[fill=yellow!60!black] coordinates {(1,5) (3,5) (3,6) (1,6)} node at (current path bounding box.center) {T8};
\addplot[fill=red!20] coordinates {(2,6) (2,8) (3,8) (3,6)} node at (current path bounding box.center) {T7};
\addplot[fill=blue!20] coordinates {(1,6) (1,10) (2,10) (2,6)} node at (current path bounding box.center) {T6};
\addplot[fill=magenta] coordinates {(2,8) (2,10) (4,10) (4,8)} node at (current path bounding box.center) {T2};
\addplot[fill=green!20] coordinates {(1,10) (1,11) (4,11) (4,10)} node at (current path bounding box.center) {T1};
\end{axis}
\end{tikzpicture}
\end{document}