# pgf stacked bar graph with line plot

I want to draw a stacked bar graph plot with one parameter as a line plot. Here is my code below -

\begin{tikzpicture}
\datatable

\definecolor{RYB1}{RGB}{51, 102, 153}
\definecolor{RYB2}{RGB}{102, 51, 0}
\definecolor{RYB3}{RGB}{204, 153, 0}
\definecolor{RYB4}{RGB}{51, 51, 0}
\definecolor{RYB5}{RGB}{204, 102, 0}

\pgfplotscreateplotcyclelist{colorbrewer-RYB}{
{fill=RYB1},
{fill=RYB2},
{fill=RYB3},
{fill=RYB4},
{fill=RYB5},
}

\begin{axis}[
symbolic x coords={1.2.1.a,1.2.3.b,1.1.3.c,1.1.1.d,1.3.1.e,1.3.3.f,3.3.3.g,1.3.3.h,1.1.3.i,1.1.1.j,1.2.1.k,1.3.1.l},
ybar stacked,
legend style={
legend columns=4,
at={(xticklabel cs:0.5)},
anchor=north,
draw=none
},
axis y line*=none,
axis x line*=bottom,
tick label style={font=\footnotesize},
legend style={font=\footnotesize},
label style={font=\footnotesize},
width=.8\textwidth,
bar width=6mm,
area legend,
x tick label style={rotate=90,anchor=east},
xlabel=Processor Configuration,
ylabel=Clock Cycles,
cycle list name=colorbrewer-RYB,
xtick=data,
xticklabels={1.2.1,1.2.3,1.1.3,1.1.1,1.3.1,1.3.3,3.3.3,1.3.3,1.1.3,1.1.1,1.2.1,1.3.1},
]
\end{axis}
\end{tikzpicture}


And here is the data file -

 A  B   C   D   E   F   G
1.2.1.a 2044238 2025137 138 15859   1400    1358
1.2.3.b 2108559 2088724 894 14662   1898    2035
1.1.3.c 3498648 3482495 1610    11490   1405    1302
1.1.1.d 2097564 2089859 871 5021    898 569
1.3.1.e 3489783 3470704 138 15888   1405    1302
1.3.3.f 3496917 3481357 871 11110   1909    1324
3.3.3.g 2110448 2089855 871 16015   2476    885
1.3.3.h 4897582 4875299 1375    17401   1903    1258
1.1.3.i 2800891 2786201 877 10704   1405    1358
1.1.1.j 2740737 2733003 894 5027    898 569
1.2.1.k 3500439 3481371 138 15882   1400    1302
1.3.1.l 2111014 2088720 894 18347   1405    1302


Now in this graph the parameter D, I would like to have it as a line plot rather than bar graph. Could anyone please tell me what I should add in the code to make it happen?

Thanks !

-
You can add sharp plot, stack plots=false to the \addplot command. –  Jake Sep 3 '12 at 14:04
I added the line - \addplot table[sharp plot, stack plots=false,y=Migrate_Fifo] from \datatable ; But it doesn't work. What I get is still the bar graph –  Raj Sep 3 '12 at 14:10
No, you have to add the options directly after \addplot, so \addplot [sharp plot, stack plots=false] table [.... I would have posted an example, but I couldn't get your code to compile. You should try to post complete and minimal example documents, instead of complicated code snippets. –  Jake Sep 3 '12 at 14:12
Great that worked ! However, I could not fix the legend to be a line. Can I somehow re-define the legend style? –  Raj Sep 3 '12 at 15:18
It might be enough to just remove the area legend from your axis options, then all the plots should automatically have the right legend style. –  Jake Sep 3 '12 at 15:20

So here is the final code which solved my problem.

\begin{tikzpicture}
\datatable

\definecolor{RYB1}{RGB}{51, 102, 153}
\definecolor{RYB2}{RGB}{102, 51, 0}
\definecolor{RYB3}{RGB}{204, 153, 0}
\definecolor{RYB4}{RGB}{51, 51, 0}
\definecolor{RYB5}{RGB}{204, 102, 0}
\pgfplotscreateplotcyclelist{colorbrewer-RYB}{
{fill=RYB1},
{fill=RYB2},
{fill=RYB3},
{fill=RYB4},
{fill=RYB5},
}

\begin{axis}[
symbolic x coords={1.2.1.a,1.2.3.b,1.1.3.c,1.1.1.d,1.3.1.e,1.3.3.f,3.3.3.g,1.3.3.h,1.1.3.i,1.1.1.j,1.2.1.k,1.3.1.l},
ybar stacked,
legend style={
legend columns=4,
at={(xticklabel cs:0.5)},
anchor=north,
draw=none
},
axis y line*=none,
axis x line*=bottom,
tick label style={font=\footnotesize},
legend style={font=\footnotesize},
width=.8\textwidth,
bar width=6mm,
x tick label style={rotate=90,anchor=east},
xlabel=Processor Configuration,
ylabel=Clock Cycles,
cycle list name=colorbrewer-RYB,
xtick=data,
xticklabels={1.2.1,1.2.3,1.1.3,1.1.1,1.3.1,1.3.3,3.3.3,1.3.3,1.1.3,1.1.1,1.2.1,1.3.1},
x label style={at={(0.5,-0.15)}},
]