
Ich möchte ein gestapeltes Balkendiagramm mit einem Parameter als Liniendiagramm zeichnen. Hier ist mein Code unten -
\begin{tikzpicture}
\pgfplotstableread{Figures/measurements.dat}
\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},
]
\addplot table[y=C] from \datatable ;
\addlegendentry{C};
\addplot table[y=E] from \datatable ;
\addlegendentry{E};
\addplot table[y=F] from \datatable ;
\addlegendentry{F};
\addplot table[y=D] from \datatable ;
\addlegendentry{D};
\end{axis}
\end{tikzpicture}
Und hier ist die Datendatei -
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
In diesem Diagramm hätte ich den Parameter D lieber als Liniendiagramm denn als Balkendiagramm. Kann mir bitte jemand sagen, was ich in den Code einfügen muss, damit das klappt?
Danke !
Antwort1
Hier ist also der endgültige Code, der mein Problem gelöst hat.
\begin{tikzpicture}
\pgfplotstableread{Figures/measurements.dat}
\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)}},
]
\addplot table[y=C] from \datatable ;
\addlegendentry{C};
\addplot table[y=E] from \datatable ;
\addlegendentry{E};
\addplot table[y=F] from \datatable ;
\addlegendentry{F};
\addplot [line legend, thick, sharp plot, stack plots=false] table[y=D] from \datatable ;
\addlegendentry{D};
\end{axis}
\end{tikzpicture}