
Quiero dibujar un gráfico de barras apiladas con un parámetro como gráfico de líneas. Aquí está mi código a continuación:
\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}
Y aquí está el archivo de datos.
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
Ahora, en este gráfico, el parámetro D, me gustaría tenerlo como un gráfico de líneas en lugar de un gráfico de barras. ¿Alguien podría decirme qué debo agregar en el código para que esto suceda?
Gracias !
Respuesta1
Aquí está el código final que resolvió mi problema.
\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}