Erro de largura de plotagem com groupplot do pgfplot no Beamer

Erro de largura de plotagem com groupplot do pgfplot no Beamer

Estou fazendo uma matriz 3x3 de gráficos em um slide beamer. A posição (1,1) está vazia, o restante da primeira linha possui títulos de colunas e o restante da primeira coluna possui títulos de linhas. As posições (2,2) a (3,3) contêm gráficos reais. Estou usando groupplots( pgfplots1.12) para fazer essa matriz.

Recebo as duas mensagens de erro a seguir:

Pacote pgfplots Aviso: Você tem um eixo com intervalo vazio (na direção y). Substituindo-o por um intervalo padrão e limpando todos os gráficos. na linha de entrada 139.

! Erro do pacote pgfplots: Erro: a largura do gráfico `28.45274pt' é muito pequena. Isso não pode ser implementado mantendo o tamanho constante dos rótulos. Desculpe, os tamanhos das etiquetas são apenas aproximados. Você precisará ajustar sua largura.

No caso do segundo erro, não sei bem onde aumentar a largura. Você pode me ajudar a corrigir meu código para não receber os erros mencionados acima?

O resultado pretendido é a imagem a seguir.

Resultado Pretendido

Meu código até agora é o seguinte:

\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}

Desde já, obrigado!

Responder1

Você não precisa usar vazio \nextgroupplotpara inserir o Row 1etc. Mas use um nó 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};

O problema de largura vem como você tem width=1cmetc naqueles vazios \nextgroupplotque são muito pequenos e pgfplotsreclamam disso.

Aqui está seu 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}

insira a descrição da imagem aqui

informação relacionada