Estoy haciendo una matriz de gráficos de 3x3 en una diapositiva. La posición (1,1) está vacía, el resto de la primera fila tiene títulos de columna y el resto de la primera columna tiene títulos de fila. Las posiciones (2,2) a (3,3) contienen gráficos reales. Estoy usando groupplots
( pgfplots
1.12) para hacer dicha matriz.
Recibo los siguientes dos mensajes de error:
Paquete pgfplots Advertencia: Tiene un eje con rango vacío (en la dirección y). Reemplazándolo con un rango predeterminado y borrando todos los gráficos. en la línea de entrada 139.
! Error del paquete pgfplots: Error: El ancho de trazado `28.45274pt' es demasiado pequeño. Esto no se puede implementar manteniendo el tamaño constante de las etiquetas. Lo sentimos, los tamaños de las etiquetas son sólo aproximados. Necesitará ajustar su ancho.
En el caso del segundo error, realmente no sé dónde aumentar el ancho. ¿Pueden ayudarme a corregir mi código para no recibir los errores mencionados anteriormente?
El resultado previsto es la siguiente imagen.
Mi código hasta ahora es el siguiente:
\documentclass{beamer}
\usepackage{pgfplots}
\usetikzlibrary{pgfplots.groupplots}
\pgfplotsset{compat=1.12}
\pgfmathdeclarefunction{gauss}{2}{%
\pgfmathparse{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}%
}
\begin{document}
\begin{frame}{Distribution Matrix}
\begin{tikzpicture}
\begin{groupplot}[
group style={
group name=my plots,
group size=3 by 3,
},
footnotesize,
tickpos=left,
ytick align=outside,
xtick align=outside,
enlarge x limits=false
]
\nextgroupplot[
width=1cm,
height=1cm,
hide axis]
\nextgroupplot[
width=5cm,
height=1cm,
no markers, domain=0:9, samples=100,
axis line style = { draw = none },
xlabel style={at={(axis description cs:0.5,-0.01)},anchor=north},
xlabel={Column 1},
ticks=none,
axis on top]
\nextgroupplot[
width=5cm,
height=1cm,
no markers, domain=0:9, samples=100,
axis line style = { draw = none },
xlabel style={at={(axis description cs:0.5,-0.01)},anchor=north},
xlabel={Column 2},
ticks=none,
axis on top]
\nextgroupplot[
width=1cm,
height=4cm,
no markers, domain=0:9, samples=100,
axis lines=center,
axis line style = { draw = none },
ylabel style={at={(axis description cs:-0.01,0.5)},rotate=90,anchor=south},
ylabel={Row 1},
ticks=none,
axis on top]
\nextgroupplot[
width=5cm,
height=4cm,
no markers, domain=0:9, samples=100,
axis lines=center,
axis line style={->},
xlabel style={at={(axis description cs:0.5,-0.01)},anchor=north},
ylabel style={at={(axis description cs:-0.01,0.5)},rotate=90,anchor=south},
ticks=none,
axis on top]
\addplot [very thick,cyan!50!black] {gauss(4,1)};
\addplot [thick,red, no markers] coordinates {(5.5,0.0) (5.5,0.4)};
\nextgroupplot[
width=5cm,
height=4cm,
no markers, domain=0:9, samples=100,
axis lines=center,
axis line style={->},
xlabel style={at={(axis description cs:0.5,-0.01)},anchor=north},
ylabel style={at={(axis description cs:-0.01,0.5)},rotate=90,anchor=south},
ticks=none,
axis on top]
\addplot [very thick,cyan!50!black] {gauss(4,1)};
\addplot [thick,red, no markers] coordinates {(5.5,0.0) (5.5,0.4)};
\nextgroupplot[
width=1cm,
height=4cm,
no markers, domain=0:9, samples=100,
axis lines=center,
axis line style = { draw = none },
ylabel style={at={(axis description cs:-0.01,0.5)},rotate=90,anchor=south},
ylabel={Row 2},
ticks=none,
axis on top]
\nextgroupplot[
width=5cm,
height=4cm,
no markers, domain=0:9, samples=100,
axis lines=center,
axis line style={->},
xlabel style={at={(axis description cs:0.5,-0.01)},anchor=north},
ylabel style={at={(axis description cs:-0.01,0.5)},rotate=90,anchor=south},
ticks=none,
axis on top]
\addplot [very thick,cyan!50!black] {gauss(4,1)};
\addplot [thick,red, no markers] coordinates {(2.5,0) (2.5,0.4)};
\addplot [thick,red, no markers] coordinates {(5.5,0.0) (5.5,0.4)};
\nextgroupplot[
width=5cm,
height=4cm,
no markers, domain=0:9, samples=100,
axis lines=center,
axis line style={->},
xlabel style={at={(axis description cs:0.5,-0.01)},anchor=north},
ylabel style={at={(axis description cs:-0.01,0.5)},rotate=90,anchor=south},
ticks=none,
axis on top]
\addplot [dashed,very thick,cyan!50!black] {gauss(4,1)};
\addplot [very thick,cyan!50!black] {gauss(5,1)};
\addplot [thick,red, no markers] coordinates {(2.5,0) (2.5,0.4)};
\addplot [thick,red, no markers] coordinates {(5.5,0.0) (5.5,0.4)};
\end{groupplot}
\end{tikzpicture}
\end{frame}
\end{document}
¡Gracias de antemano!
Respuesta1
No es necesario utilizar vacío \nextgroupplot
para insertar el Row 1
etc. Pero utilice un nodo como
\node[rotate=90,above=5mm] at (my plots c1r1.west) {Row 1};
\node[rotate=90,above=5mm] at (my plots c1r2.west) {Row 2};
\node[above=5mm] at (my plots c1r1.north) {Column 1};
\node[above=5mm] at (my plots c2r1.north) {Column 2};
El problema del ancho viene porque tienes width=1cm
etc en esos s vacíos \nextgroupplot
que son muy pequeños y pgfplots
se queja de ello.
Aquí está su código refinado:
\documentclass{beamer}
\usepackage{pgfplots}
\usetikzlibrary{pgfplots.groupplots}
\pgfplotsset{compat=1.12}
\pgfmathdeclarefunction{gauss}{2}{%
\pgfmathparse{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}%
}
\begin{document}
\begin{frame}{Distribution Matrix}
%\centering if you want to center this
\begin{tikzpicture}
\begin{groupplot}[
group style={
group name=my plots,
group size=2 by 2,
},
footnotesize,
tickpos=left,
ytick align=outside,
xtick align=outside,
enlarge x limits=false
]
\nextgroupplot[
width=5cm,
height=4cm,
no markers, domain=0:9, samples=100,
axis lines=center,
axis line style={->},
xlabel style={at={(axis description cs:0.5,-0.01)},anchor=north},
ylabel style={at={(axis description cs:-0.01,0.5)},rotate=90,anchor=south},
ticks=none,
axis on top]
\addplot [very thick,cyan!50!black] {gauss(4,1)};
\addplot [thick,red, no markers] coordinates {(5.5,0.0) (5.5,0.4)};
\nextgroupplot[
width=5cm,
height=4cm,
no markers, domain=0:9, samples=100,
axis lines=center,
axis line style={->},
xlabel style={at={(axis description cs:0.5,-0.01)},anchor=north},
ylabel style={at={(axis description cs:-0.01,0.5)},rotate=90,anchor=south},
ticks=none,
axis on top]
\addplot [very thick,cyan!50!black] {gauss(4,1)};
\addplot [thick,red, no markers] coordinates {(5.5,0.0) (5.5,0.4)};
\nextgroupplot[
width=5cm,
height=4cm,
no markers, domain=0:9, samples=100,
axis lines=center,
axis line style={->},
xlabel style={at={(axis description cs:0.5,-0.01)},anchor=north},
ylabel style={at={(axis description cs:-0.01,0.5)},rotate=90,anchor=south},
ticks=none,
axis on top]
\addplot [very thick,cyan!50!black] {gauss(4,1)};
\addplot [thick,red, no markers] coordinates {(2.5,0) (2.5,0.4)};
\addplot [thick,red, no markers] coordinates {(5.5,0.0) (5.5,0.4)};
\nextgroupplot[
width=5cm,
height=4cm,
no markers, domain=0:9, samples=100,
axis lines=center,
axis line style={->},
xlabel style={at={(axis description cs:0.5,-0.01)},anchor=north},
ylabel style={at={(axis description cs:-0.01,0.5)},rotate=90,anchor=south},
ticks=none,
axis on top]
\addplot [dashed,very thick,cyan!50!black] {gauss(4,1)};
\addplot [very thick,cyan!50!black] {gauss(5,1)};
\addplot [thick,red, no markers] coordinates {(2.5,0) (2.5,0.4)};
\addplot [thick,red, no markers] coordinates {(5.5,0.0) (5.5,0.4)};
\end{groupplot}
\node[rotate=90,above=5mm] at (my plots c1r1.west) {Row 1};
\node[rotate=90,above=5mm] at (my plots c1r2.west) {Row 2};
\node[above=5mm] at (my plots c1r1.north) {Column 1};
\node[above=5mm] at (my plots c2r1.north) {Column 2};
\end{tikzpicture}
\end{frame}
\end{document}