PGFPlots + TikZ: Stranger Beamer behavior












1















I am trying to include a PGFPlots + TikZ figure in a beamer presentation made with the metropolis theme. If I compile the figure in a normal article class (or standalone), the figure is fine. The code for the figure is the following:



documentclass[tikz]{standalone}
usetikzlibrary{shapes}
usepackage{pgfplots}
pgfplotsset{compat=newest}

usepackage[utf8]{inputenc} % Required for including letters with accents

begin{document}

begin{tikzpicture}
begin{axis}[
width=textwidth,
height=8cm,
hide y axis,
axis x line*=bottom,
xtick={-3,-2,-1,0,1,2,3},
xticklabels={$bar x-3s$,$bar x-2s$,$bar x-s$,$bar x$,$bar x+s$,$bar x+2s$,$bar x+3s$},
xmin = -3.5,
xmax = 3.5,
ymin = 0,
ymax = 0.9,
]
draw[dashed] (axis cs:-3,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-3,0.85);
draw[dashed] (axis cs:-2,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-2,0.7);
draw[dashed] (axis cs:-1,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-1,0.55);
draw[dashed] (axis cs:1,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:1,0.55);
draw[dashed] (axis cs:2,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:2,0.7);
draw[dashed] (axis cs:3,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:3,0.85);
draw[stealth-stealth](-1,0.55) -- (1,0.55) node[midway,fill=white]{68%};
node at(0,0.5) {1 desviación};
node at(0,0.45) {estándar};
draw[stealth-stealth](-2,0.7) -- (2,0.7) node[midway,fill=white]{95%};
node at(0,0.65) {2 desviaciones estándar};
draw[stealth-stealth](-3,0.85) -- (3,0.85) node[midway,fill=white]{99.7%};
node at(0,0.8) {3 desviaciones estándar};
addplot[samples=201,ultra thick] {exp(-x^2/2)/sqrt(2*pi)};
draw[thick,dashed] (axis cs:0,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:0,{1/sqrt(2*pi)});
end{axis}
end{tikzpicture}

end{document}


This produces this figure:
Standalone Test



If I now try to put that figure inside a beamer presentation (using the metropolis theme), the code I am using is:



%!TEX TS-program = xelatex

documentclass{beamer}
usetheme{metropolis} % Use metropolis theme

usepackage[utf8]{inputenc} % Required for including letters with accents

usepackage{tikz}
usetikzlibrary{shapes}
usepackage{pgfplots}
pgfplotsset{compat=newest}

begin{document}
begin{frame}{Test}
centering
begin{tikzpicture}
begin{axis}[
width=textwidth,
height=8cm,
hide y axis,
axis x line*=bottom,
xtick={-3,-2,-1,0,1,2,3},
xticklabels={$bar x-3s$,$bar x-2s$,$bar x-s$,$bar x$,$bar x+s$,$bar x+2s$,$bar x+3s$},
xmin = -3.5,
xmax = 3.5,
ymin = 0,
ymax = 0.9,
]
draw[dashed] (axis cs:-3,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-3,0.85);
draw[dashed] (axis cs:-2,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-2,0.7);
draw[dashed] (axis cs:-1,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-1,0.55);
draw[dashed] (axis cs:1,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:1,0.55);
draw[dashed] (axis cs:2,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:2,0.7);
draw[dashed] (axis cs:3,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:3,0.85);
draw[stealth-stealth](-1,0.55) -- (1,0.55) node[midway,fill=white]{68%};
node at(0,0.5) {1 desviación};
node at(0,0.45) {estándar};
draw[stealth-stealth](-2,0.7) -- (2,0.7) node[midway,fill=white]{95%};
node at(0,0.65) {2 desviaciones estándar};
draw[stealth-stealth](-3,0.85) -- (3,0.85) node[midway,fill=white]{99.7%};
node at(0,0.8) {3 desviaciones estándar};
addplot[samples=201,ultra thick] {exp(-x^2/2)/sqrt(2*pi)};
draw[thick,dashed] (axis cs:0,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:0,{1/sqrt(2*pi)});
end{axis}
end{tikzpicture}
end{frame}
end{document}


which produces this when compiled:



Beamer Test



I have no clue about what is happening. Any help will be much appreciated.










share|improve this question





























    1















    I am trying to include a PGFPlots + TikZ figure in a beamer presentation made with the metropolis theme. If I compile the figure in a normal article class (or standalone), the figure is fine. The code for the figure is the following:



    documentclass[tikz]{standalone}
    usetikzlibrary{shapes}
    usepackage{pgfplots}
    pgfplotsset{compat=newest}

    usepackage[utf8]{inputenc} % Required for including letters with accents

    begin{document}

    begin{tikzpicture}
    begin{axis}[
    width=textwidth,
    height=8cm,
    hide y axis,
    axis x line*=bottom,
    xtick={-3,-2,-1,0,1,2,3},
    xticklabels={$bar x-3s$,$bar x-2s$,$bar x-s$,$bar x$,$bar x+s$,$bar x+2s$,$bar x+3s$},
    xmin = -3.5,
    xmax = 3.5,
    ymin = 0,
    ymax = 0.9,
    ]
    draw[dashed] (axis cs:-3,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-3,0.85);
    draw[dashed] (axis cs:-2,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-2,0.7);
    draw[dashed] (axis cs:-1,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-1,0.55);
    draw[dashed] (axis cs:1,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:1,0.55);
    draw[dashed] (axis cs:2,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:2,0.7);
    draw[dashed] (axis cs:3,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:3,0.85);
    draw[stealth-stealth](-1,0.55) -- (1,0.55) node[midway,fill=white]{68%};
    node at(0,0.5) {1 desviación};
    node at(0,0.45) {estándar};
    draw[stealth-stealth](-2,0.7) -- (2,0.7) node[midway,fill=white]{95%};
    node at(0,0.65) {2 desviaciones estándar};
    draw[stealth-stealth](-3,0.85) -- (3,0.85) node[midway,fill=white]{99.7%};
    node at(0,0.8) {3 desviaciones estándar};
    addplot[samples=201,ultra thick] {exp(-x^2/2)/sqrt(2*pi)};
    draw[thick,dashed] (axis cs:0,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:0,{1/sqrt(2*pi)});
    end{axis}
    end{tikzpicture}

    end{document}


    This produces this figure:
    Standalone Test



    If I now try to put that figure inside a beamer presentation (using the metropolis theme), the code I am using is:



    %!TEX TS-program = xelatex

    documentclass{beamer}
    usetheme{metropolis} % Use metropolis theme

    usepackage[utf8]{inputenc} % Required for including letters with accents

    usepackage{tikz}
    usetikzlibrary{shapes}
    usepackage{pgfplots}
    pgfplotsset{compat=newest}

    begin{document}
    begin{frame}{Test}
    centering
    begin{tikzpicture}
    begin{axis}[
    width=textwidth,
    height=8cm,
    hide y axis,
    axis x line*=bottom,
    xtick={-3,-2,-1,0,1,2,3},
    xticklabels={$bar x-3s$,$bar x-2s$,$bar x-s$,$bar x$,$bar x+s$,$bar x+2s$,$bar x+3s$},
    xmin = -3.5,
    xmax = 3.5,
    ymin = 0,
    ymax = 0.9,
    ]
    draw[dashed] (axis cs:-3,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-3,0.85);
    draw[dashed] (axis cs:-2,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-2,0.7);
    draw[dashed] (axis cs:-1,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-1,0.55);
    draw[dashed] (axis cs:1,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:1,0.55);
    draw[dashed] (axis cs:2,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:2,0.7);
    draw[dashed] (axis cs:3,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:3,0.85);
    draw[stealth-stealth](-1,0.55) -- (1,0.55) node[midway,fill=white]{68%};
    node at(0,0.5) {1 desviación};
    node at(0,0.45) {estándar};
    draw[stealth-stealth](-2,0.7) -- (2,0.7) node[midway,fill=white]{95%};
    node at(0,0.65) {2 desviaciones estándar};
    draw[stealth-stealth](-3,0.85) -- (3,0.85) node[midway,fill=white]{99.7%};
    node at(0,0.8) {3 desviaciones estándar};
    addplot[samples=201,ultra thick] {exp(-x^2/2)/sqrt(2*pi)};
    draw[thick,dashed] (axis cs:0,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:0,{1/sqrt(2*pi)});
    end{axis}
    end{tikzpicture}
    end{frame}
    end{document}


    which produces this when compiled:



    Beamer Test



    I have no clue about what is happening. Any help will be much appreciated.










    share|improve this question



























      1












      1








      1








      I am trying to include a PGFPlots + TikZ figure in a beamer presentation made with the metropolis theme. If I compile the figure in a normal article class (or standalone), the figure is fine. The code for the figure is the following:



      documentclass[tikz]{standalone}
      usetikzlibrary{shapes}
      usepackage{pgfplots}
      pgfplotsset{compat=newest}

      usepackage[utf8]{inputenc} % Required for including letters with accents

      begin{document}

      begin{tikzpicture}
      begin{axis}[
      width=textwidth,
      height=8cm,
      hide y axis,
      axis x line*=bottom,
      xtick={-3,-2,-1,0,1,2,3},
      xticklabels={$bar x-3s$,$bar x-2s$,$bar x-s$,$bar x$,$bar x+s$,$bar x+2s$,$bar x+3s$},
      xmin = -3.5,
      xmax = 3.5,
      ymin = 0,
      ymax = 0.9,
      ]
      draw[dashed] (axis cs:-3,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-3,0.85);
      draw[dashed] (axis cs:-2,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-2,0.7);
      draw[dashed] (axis cs:-1,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-1,0.55);
      draw[dashed] (axis cs:1,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:1,0.55);
      draw[dashed] (axis cs:2,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:2,0.7);
      draw[dashed] (axis cs:3,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:3,0.85);
      draw[stealth-stealth](-1,0.55) -- (1,0.55) node[midway,fill=white]{68%};
      node at(0,0.5) {1 desviación};
      node at(0,0.45) {estándar};
      draw[stealth-stealth](-2,0.7) -- (2,0.7) node[midway,fill=white]{95%};
      node at(0,0.65) {2 desviaciones estándar};
      draw[stealth-stealth](-3,0.85) -- (3,0.85) node[midway,fill=white]{99.7%};
      node at(0,0.8) {3 desviaciones estándar};
      addplot[samples=201,ultra thick] {exp(-x^2/2)/sqrt(2*pi)};
      draw[thick,dashed] (axis cs:0,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:0,{1/sqrt(2*pi)});
      end{axis}
      end{tikzpicture}

      end{document}


      This produces this figure:
      Standalone Test



      If I now try to put that figure inside a beamer presentation (using the metropolis theme), the code I am using is:



      %!TEX TS-program = xelatex

      documentclass{beamer}
      usetheme{metropolis} % Use metropolis theme

      usepackage[utf8]{inputenc} % Required for including letters with accents

      usepackage{tikz}
      usetikzlibrary{shapes}
      usepackage{pgfplots}
      pgfplotsset{compat=newest}

      begin{document}
      begin{frame}{Test}
      centering
      begin{tikzpicture}
      begin{axis}[
      width=textwidth,
      height=8cm,
      hide y axis,
      axis x line*=bottom,
      xtick={-3,-2,-1,0,1,2,3},
      xticklabels={$bar x-3s$,$bar x-2s$,$bar x-s$,$bar x$,$bar x+s$,$bar x+2s$,$bar x+3s$},
      xmin = -3.5,
      xmax = 3.5,
      ymin = 0,
      ymax = 0.9,
      ]
      draw[dashed] (axis cs:-3,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-3,0.85);
      draw[dashed] (axis cs:-2,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-2,0.7);
      draw[dashed] (axis cs:-1,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-1,0.55);
      draw[dashed] (axis cs:1,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:1,0.55);
      draw[dashed] (axis cs:2,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:2,0.7);
      draw[dashed] (axis cs:3,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:3,0.85);
      draw[stealth-stealth](-1,0.55) -- (1,0.55) node[midway,fill=white]{68%};
      node at(0,0.5) {1 desviación};
      node at(0,0.45) {estándar};
      draw[stealth-stealth](-2,0.7) -- (2,0.7) node[midway,fill=white]{95%};
      node at(0,0.65) {2 desviaciones estándar};
      draw[stealth-stealth](-3,0.85) -- (3,0.85) node[midway,fill=white]{99.7%};
      node at(0,0.8) {3 desviaciones estándar};
      addplot[samples=201,ultra thick] {exp(-x^2/2)/sqrt(2*pi)};
      draw[thick,dashed] (axis cs:0,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:0,{1/sqrt(2*pi)});
      end{axis}
      end{tikzpicture}
      end{frame}
      end{document}


      which produces this when compiled:



      Beamer Test



      I have no clue about what is happening. Any help will be much appreciated.










      share|improve this question
















      I am trying to include a PGFPlots + TikZ figure in a beamer presentation made with the metropolis theme. If I compile the figure in a normal article class (or standalone), the figure is fine. The code for the figure is the following:



      documentclass[tikz]{standalone}
      usetikzlibrary{shapes}
      usepackage{pgfplots}
      pgfplotsset{compat=newest}

      usepackage[utf8]{inputenc} % Required for including letters with accents

      begin{document}

      begin{tikzpicture}
      begin{axis}[
      width=textwidth,
      height=8cm,
      hide y axis,
      axis x line*=bottom,
      xtick={-3,-2,-1,0,1,2,3},
      xticklabels={$bar x-3s$,$bar x-2s$,$bar x-s$,$bar x$,$bar x+s$,$bar x+2s$,$bar x+3s$},
      xmin = -3.5,
      xmax = 3.5,
      ymin = 0,
      ymax = 0.9,
      ]
      draw[dashed] (axis cs:-3,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-3,0.85);
      draw[dashed] (axis cs:-2,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-2,0.7);
      draw[dashed] (axis cs:-1,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-1,0.55);
      draw[dashed] (axis cs:1,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:1,0.55);
      draw[dashed] (axis cs:2,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:2,0.7);
      draw[dashed] (axis cs:3,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:3,0.85);
      draw[stealth-stealth](-1,0.55) -- (1,0.55) node[midway,fill=white]{68%};
      node at(0,0.5) {1 desviación};
      node at(0,0.45) {estándar};
      draw[stealth-stealth](-2,0.7) -- (2,0.7) node[midway,fill=white]{95%};
      node at(0,0.65) {2 desviaciones estándar};
      draw[stealth-stealth](-3,0.85) -- (3,0.85) node[midway,fill=white]{99.7%};
      node at(0,0.8) {3 desviaciones estándar};
      addplot[samples=201,ultra thick] {exp(-x^2/2)/sqrt(2*pi)};
      draw[thick,dashed] (axis cs:0,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:0,{1/sqrt(2*pi)});
      end{axis}
      end{tikzpicture}

      end{document}


      This produces this figure:
      Standalone Test



      If I now try to put that figure inside a beamer presentation (using the metropolis theme), the code I am using is:



      %!TEX TS-program = xelatex

      documentclass{beamer}
      usetheme{metropolis} % Use metropolis theme

      usepackage[utf8]{inputenc} % Required for including letters with accents

      usepackage{tikz}
      usetikzlibrary{shapes}
      usepackage{pgfplots}
      pgfplotsset{compat=newest}

      begin{document}
      begin{frame}{Test}
      centering
      begin{tikzpicture}
      begin{axis}[
      width=textwidth,
      height=8cm,
      hide y axis,
      axis x line*=bottom,
      xtick={-3,-2,-1,0,1,2,3},
      xticklabels={$bar x-3s$,$bar x-2s$,$bar x-s$,$bar x$,$bar x+s$,$bar x+2s$,$bar x+3s$},
      xmin = -3.5,
      xmax = 3.5,
      ymin = 0,
      ymax = 0.9,
      ]
      draw[dashed] (axis cs:-3,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-3,0.85);
      draw[dashed] (axis cs:-2,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-2,0.7);
      draw[dashed] (axis cs:-1,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-1,0.55);
      draw[dashed] (axis cs:1,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:1,0.55);
      draw[dashed] (axis cs:2,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:2,0.7);
      draw[dashed] (axis cs:3,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:3,0.85);
      draw[stealth-stealth](-1,0.55) -- (1,0.55) node[midway,fill=white]{68%};
      node at(0,0.5) {1 desviación};
      node at(0,0.45) {estándar};
      draw[stealth-stealth](-2,0.7) -- (2,0.7) node[midway,fill=white]{95%};
      node at(0,0.65) {2 desviaciones estándar};
      draw[stealth-stealth](-3,0.85) -- (3,0.85) node[midway,fill=white]{99.7%};
      node at(0,0.8) {3 desviaciones estándar};
      addplot[samples=201,ultra thick] {exp(-x^2/2)/sqrt(2*pi)};
      draw[thick,dashed] (axis cs:0,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:0,{1/sqrt(2*pi)});
      end{axis}
      end{tikzpicture}
      end{frame}
      end{document}


      which produces this when compiled:



      Beamer Test



      I have no clue about what is happening. Any help will be much appreciated.







      tikz-pgf beamer pgfplots beamer-metropolis






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 15 at 22:16









      samcarter

      87.9k797281




      87.9k797281










      asked Aug 23 '17 at 17:08









      RAORAO

      254




      254






















          1 Answer
          1






          active

          oldest

          votes


















          6














          So after a bit of detective work, it turns out that the problem is caused by




          • the metropolis theme

          • and therein from the pgfplotsthemetol package which is loaded at the end of the peramble

          • which sets pgfplotsset{compat=1.9}


          as a workaround, use pgfplotsset{compat=newest} after begin{document}



          %!TEX TS-program = xelatex

          documentclass{beamer}
          usetheme{metropolis} % Use metropolis theme
          %

          usepackage[utf8]{inputenc} % Required for including letters with accents

          usepackage{tikz}
          usetikzlibrary{shapes}
          usepackage{pgfplots}
          pgfplotsset{compat=newest}

          begin{document}
          pgfplotsset{compat=newest}
          begin{frame}{Test}
          centering
          begin{tikzpicture}[x=1cm,y=1cm]
          begin{axis}[
          width=textwidth,
          height=8cm,
          hide y axis,
          axis x line*=bottom,
          xtick={-3,-2,-1,0,1,2,3},
          xticklabels={$bar x-3s$,$bar x-2s$,$bar x-s$,$bar x$,$bar x+s$,$bar x+2s$,$bar x+3s$},
          xmin = -3.5,
          xmax = 3.5,
          ymin = 0,
          ymax = 0.9,
          ]
          draw[dashed] (axis cs:-3,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-3,0.85);
          draw[dashed] (axis cs:-2,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-2,0.7);
          draw[dashed] (axis cs:-1,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-1,0.55);
          draw[dashed] (axis cs:1,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:1,0.55);
          draw[dashed] (axis cs:2,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:2,0.7);
          draw[dashed] (axis cs:3,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:3,0.85);
          begin{scope}
          draw[stealth-stealth](-1,0.55) -- (1,0.55) node[midway,fill=white]{68%};
          node at(0,0.5) {1 desviación};
          node at(0,0.45) {estándar};
          draw[stealth-stealth](-2,0.7) -- (2,0.7) node[midway,fill=white]{95%};
          node at(0,0.65) {2 desviaciones estándar};
          draw[stealth-stealth](-3,0.85) -- (3,0.85) node[midway,fill=white]{99.7%};
          node at(0,0.8) {3 desviaciones estándar};
          end{scope}
          addplot[samples=201,ultra thick] {exp(-x^2/2)/sqrt(2*pi)};
          draw[thick,dashed] (axis cs:0,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:0,{1/sqrt(2*pi)});
          end{axis}
          end{tikzpicture}
          end{frame}
          end{document}


          enter image description here






          share|improve this answer
























          • Thank you very much @samcarter! Indeed this solved the problem. I will warn the metropolisdevelopers. I have no idea how the LaTeX engine works but shouldn't pgfplotsset{compat=newest}override any previous version statement, even putting it in the preamble?

            – RAO
            Aug 24 '17 at 7:48











          • @RAO It does overwrite the previous statement, but metropolis instructs to load pgfplotsset{compat=1.9} at the end of the preamble and thus overwrites your statement which was issued before.

            – samcarter
            Aug 24 '17 at 8:19











          • Oh I see. I will ask the metropolisdevelopers to have a look at it. Thank you very much!

            – RAO
            Aug 24 '17 at 10:05











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "85"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f387870%2fpgfplots-tikz-stranger-beamer-behavior%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          6














          So after a bit of detective work, it turns out that the problem is caused by




          • the metropolis theme

          • and therein from the pgfplotsthemetol package which is loaded at the end of the peramble

          • which sets pgfplotsset{compat=1.9}


          as a workaround, use pgfplotsset{compat=newest} after begin{document}



          %!TEX TS-program = xelatex

          documentclass{beamer}
          usetheme{metropolis} % Use metropolis theme
          %

          usepackage[utf8]{inputenc} % Required for including letters with accents

          usepackage{tikz}
          usetikzlibrary{shapes}
          usepackage{pgfplots}
          pgfplotsset{compat=newest}

          begin{document}
          pgfplotsset{compat=newest}
          begin{frame}{Test}
          centering
          begin{tikzpicture}[x=1cm,y=1cm]
          begin{axis}[
          width=textwidth,
          height=8cm,
          hide y axis,
          axis x line*=bottom,
          xtick={-3,-2,-1,0,1,2,3},
          xticklabels={$bar x-3s$,$bar x-2s$,$bar x-s$,$bar x$,$bar x+s$,$bar x+2s$,$bar x+3s$},
          xmin = -3.5,
          xmax = 3.5,
          ymin = 0,
          ymax = 0.9,
          ]
          draw[dashed] (axis cs:-3,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-3,0.85);
          draw[dashed] (axis cs:-2,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-2,0.7);
          draw[dashed] (axis cs:-1,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-1,0.55);
          draw[dashed] (axis cs:1,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:1,0.55);
          draw[dashed] (axis cs:2,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:2,0.7);
          draw[dashed] (axis cs:3,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:3,0.85);
          begin{scope}
          draw[stealth-stealth](-1,0.55) -- (1,0.55) node[midway,fill=white]{68%};
          node at(0,0.5) {1 desviación};
          node at(0,0.45) {estándar};
          draw[stealth-stealth](-2,0.7) -- (2,0.7) node[midway,fill=white]{95%};
          node at(0,0.65) {2 desviaciones estándar};
          draw[stealth-stealth](-3,0.85) -- (3,0.85) node[midway,fill=white]{99.7%};
          node at(0,0.8) {3 desviaciones estándar};
          end{scope}
          addplot[samples=201,ultra thick] {exp(-x^2/2)/sqrt(2*pi)};
          draw[thick,dashed] (axis cs:0,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:0,{1/sqrt(2*pi)});
          end{axis}
          end{tikzpicture}
          end{frame}
          end{document}


          enter image description here






          share|improve this answer
























          • Thank you very much @samcarter! Indeed this solved the problem. I will warn the metropolisdevelopers. I have no idea how the LaTeX engine works but shouldn't pgfplotsset{compat=newest}override any previous version statement, even putting it in the preamble?

            – RAO
            Aug 24 '17 at 7:48











          • @RAO It does overwrite the previous statement, but metropolis instructs to load pgfplotsset{compat=1.9} at the end of the preamble and thus overwrites your statement which was issued before.

            – samcarter
            Aug 24 '17 at 8:19











          • Oh I see. I will ask the metropolisdevelopers to have a look at it. Thank you very much!

            – RAO
            Aug 24 '17 at 10:05
















          6














          So after a bit of detective work, it turns out that the problem is caused by




          • the metropolis theme

          • and therein from the pgfplotsthemetol package which is loaded at the end of the peramble

          • which sets pgfplotsset{compat=1.9}


          as a workaround, use pgfplotsset{compat=newest} after begin{document}



          %!TEX TS-program = xelatex

          documentclass{beamer}
          usetheme{metropolis} % Use metropolis theme
          %

          usepackage[utf8]{inputenc} % Required for including letters with accents

          usepackage{tikz}
          usetikzlibrary{shapes}
          usepackage{pgfplots}
          pgfplotsset{compat=newest}

          begin{document}
          pgfplotsset{compat=newest}
          begin{frame}{Test}
          centering
          begin{tikzpicture}[x=1cm,y=1cm]
          begin{axis}[
          width=textwidth,
          height=8cm,
          hide y axis,
          axis x line*=bottom,
          xtick={-3,-2,-1,0,1,2,3},
          xticklabels={$bar x-3s$,$bar x-2s$,$bar x-s$,$bar x$,$bar x+s$,$bar x+2s$,$bar x+3s$},
          xmin = -3.5,
          xmax = 3.5,
          ymin = 0,
          ymax = 0.9,
          ]
          draw[dashed] (axis cs:-3,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-3,0.85);
          draw[dashed] (axis cs:-2,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-2,0.7);
          draw[dashed] (axis cs:-1,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-1,0.55);
          draw[dashed] (axis cs:1,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:1,0.55);
          draw[dashed] (axis cs:2,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:2,0.7);
          draw[dashed] (axis cs:3,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:3,0.85);
          begin{scope}
          draw[stealth-stealth](-1,0.55) -- (1,0.55) node[midway,fill=white]{68%};
          node at(0,0.5) {1 desviación};
          node at(0,0.45) {estándar};
          draw[stealth-stealth](-2,0.7) -- (2,0.7) node[midway,fill=white]{95%};
          node at(0,0.65) {2 desviaciones estándar};
          draw[stealth-stealth](-3,0.85) -- (3,0.85) node[midway,fill=white]{99.7%};
          node at(0,0.8) {3 desviaciones estándar};
          end{scope}
          addplot[samples=201,ultra thick] {exp(-x^2/2)/sqrt(2*pi)};
          draw[thick,dashed] (axis cs:0,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:0,{1/sqrt(2*pi)});
          end{axis}
          end{tikzpicture}
          end{frame}
          end{document}


          enter image description here






          share|improve this answer
























          • Thank you very much @samcarter! Indeed this solved the problem. I will warn the metropolisdevelopers. I have no idea how the LaTeX engine works but shouldn't pgfplotsset{compat=newest}override any previous version statement, even putting it in the preamble?

            – RAO
            Aug 24 '17 at 7:48











          • @RAO It does overwrite the previous statement, but metropolis instructs to load pgfplotsset{compat=1.9} at the end of the preamble and thus overwrites your statement which was issued before.

            – samcarter
            Aug 24 '17 at 8:19











          • Oh I see. I will ask the metropolisdevelopers to have a look at it. Thank you very much!

            – RAO
            Aug 24 '17 at 10:05














          6












          6








          6







          So after a bit of detective work, it turns out that the problem is caused by




          • the metropolis theme

          • and therein from the pgfplotsthemetol package which is loaded at the end of the peramble

          • which sets pgfplotsset{compat=1.9}


          as a workaround, use pgfplotsset{compat=newest} after begin{document}



          %!TEX TS-program = xelatex

          documentclass{beamer}
          usetheme{metropolis} % Use metropolis theme
          %

          usepackage[utf8]{inputenc} % Required for including letters with accents

          usepackage{tikz}
          usetikzlibrary{shapes}
          usepackage{pgfplots}
          pgfplotsset{compat=newest}

          begin{document}
          pgfplotsset{compat=newest}
          begin{frame}{Test}
          centering
          begin{tikzpicture}[x=1cm,y=1cm]
          begin{axis}[
          width=textwidth,
          height=8cm,
          hide y axis,
          axis x line*=bottom,
          xtick={-3,-2,-1,0,1,2,3},
          xticklabels={$bar x-3s$,$bar x-2s$,$bar x-s$,$bar x$,$bar x+s$,$bar x+2s$,$bar x+3s$},
          xmin = -3.5,
          xmax = 3.5,
          ymin = 0,
          ymax = 0.9,
          ]
          draw[dashed] (axis cs:-3,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-3,0.85);
          draw[dashed] (axis cs:-2,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-2,0.7);
          draw[dashed] (axis cs:-1,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-1,0.55);
          draw[dashed] (axis cs:1,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:1,0.55);
          draw[dashed] (axis cs:2,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:2,0.7);
          draw[dashed] (axis cs:3,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:3,0.85);
          begin{scope}
          draw[stealth-stealth](-1,0.55) -- (1,0.55) node[midway,fill=white]{68%};
          node at(0,0.5) {1 desviación};
          node at(0,0.45) {estándar};
          draw[stealth-stealth](-2,0.7) -- (2,0.7) node[midway,fill=white]{95%};
          node at(0,0.65) {2 desviaciones estándar};
          draw[stealth-stealth](-3,0.85) -- (3,0.85) node[midway,fill=white]{99.7%};
          node at(0,0.8) {3 desviaciones estándar};
          end{scope}
          addplot[samples=201,ultra thick] {exp(-x^2/2)/sqrt(2*pi)};
          draw[thick,dashed] (axis cs:0,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:0,{1/sqrt(2*pi)});
          end{axis}
          end{tikzpicture}
          end{frame}
          end{document}


          enter image description here






          share|improve this answer













          So after a bit of detective work, it turns out that the problem is caused by




          • the metropolis theme

          • and therein from the pgfplotsthemetol package which is loaded at the end of the peramble

          • which sets pgfplotsset{compat=1.9}


          as a workaround, use pgfplotsset{compat=newest} after begin{document}



          %!TEX TS-program = xelatex

          documentclass{beamer}
          usetheme{metropolis} % Use metropolis theme
          %

          usepackage[utf8]{inputenc} % Required for including letters with accents

          usepackage{tikz}
          usetikzlibrary{shapes}
          usepackage{pgfplots}
          pgfplotsset{compat=newest}

          begin{document}
          pgfplotsset{compat=newest}
          begin{frame}{Test}
          centering
          begin{tikzpicture}[x=1cm,y=1cm]
          begin{axis}[
          width=textwidth,
          height=8cm,
          hide y axis,
          axis x line*=bottom,
          xtick={-3,-2,-1,0,1,2,3},
          xticklabels={$bar x-3s$,$bar x-2s$,$bar x-s$,$bar x$,$bar x+s$,$bar x+2s$,$bar x+3s$},
          xmin = -3.5,
          xmax = 3.5,
          ymin = 0,
          ymax = 0.9,
          ]
          draw[dashed] (axis cs:-3,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-3,0.85);
          draw[dashed] (axis cs:-2,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-2,0.7);
          draw[dashed] (axis cs:-1,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:-1,0.55);
          draw[dashed] (axis cs:1,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:1,0.55);
          draw[dashed] (axis cs:2,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:2,0.7);
          draw[dashed] (axis cs:3,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:3,0.85);
          begin{scope}
          draw[stealth-stealth](-1,0.55) -- (1,0.55) node[midway,fill=white]{68%};
          node at(0,0.5) {1 desviación};
          node at(0,0.45) {estándar};
          draw[stealth-stealth](-2,0.7) -- (2,0.7) node[midway,fill=white]{95%};
          node at(0,0.65) {2 desviaciones estándar};
          draw[stealth-stealth](-3,0.85) -- (3,0.85) node[midway,fill=white]{99.7%};
          node at(0,0.8) {3 desviaciones estándar};
          end{scope}
          addplot[samples=201,ultra thick] {exp(-x^2/2)/sqrt(2*pi)};
          draw[thick,dashed] (axis cs:0,pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:0,{1/sqrt(2*pi)});
          end{axis}
          end{tikzpicture}
          end{frame}
          end{document}


          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Aug 23 '17 at 17:36









          samcartersamcarter

          87.9k797281




          87.9k797281













          • Thank you very much @samcarter! Indeed this solved the problem. I will warn the metropolisdevelopers. I have no idea how the LaTeX engine works but shouldn't pgfplotsset{compat=newest}override any previous version statement, even putting it in the preamble?

            – RAO
            Aug 24 '17 at 7:48











          • @RAO It does overwrite the previous statement, but metropolis instructs to load pgfplotsset{compat=1.9} at the end of the preamble and thus overwrites your statement which was issued before.

            – samcarter
            Aug 24 '17 at 8:19











          • Oh I see. I will ask the metropolisdevelopers to have a look at it. Thank you very much!

            – RAO
            Aug 24 '17 at 10:05



















          • Thank you very much @samcarter! Indeed this solved the problem. I will warn the metropolisdevelopers. I have no idea how the LaTeX engine works but shouldn't pgfplotsset{compat=newest}override any previous version statement, even putting it in the preamble?

            – RAO
            Aug 24 '17 at 7:48











          • @RAO It does overwrite the previous statement, but metropolis instructs to load pgfplotsset{compat=1.9} at the end of the preamble and thus overwrites your statement which was issued before.

            – samcarter
            Aug 24 '17 at 8:19











          • Oh I see. I will ask the metropolisdevelopers to have a look at it. Thank you very much!

            – RAO
            Aug 24 '17 at 10:05

















          Thank you very much @samcarter! Indeed this solved the problem. I will warn the metropolisdevelopers. I have no idea how the LaTeX engine works but shouldn't pgfplotsset{compat=newest}override any previous version statement, even putting it in the preamble?

          – RAO
          Aug 24 '17 at 7:48





          Thank you very much @samcarter! Indeed this solved the problem. I will warn the metropolisdevelopers. I have no idea how the LaTeX engine works but shouldn't pgfplotsset{compat=newest}override any previous version statement, even putting it in the preamble?

          – RAO
          Aug 24 '17 at 7:48













          @RAO It does overwrite the previous statement, but metropolis instructs to load pgfplotsset{compat=1.9} at the end of the preamble and thus overwrites your statement which was issued before.

          – samcarter
          Aug 24 '17 at 8:19





          @RAO It does overwrite the previous statement, but metropolis instructs to load pgfplotsset{compat=1.9} at the end of the preamble and thus overwrites your statement which was issued before.

          – samcarter
          Aug 24 '17 at 8:19













          Oh I see. I will ask the metropolisdevelopers to have a look at it. Thank you very much!

          – RAO
          Aug 24 '17 at 10:05





          Oh I see. I will ask the metropolisdevelopers to have a look at it. Thank you very much!

          – RAO
          Aug 24 '17 at 10:05


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f387870%2fpgfplots-tikz-stranger-beamer-behavior%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to change which sound is reproduced for terminal bell?

          Can I use Tabulator js library in my java Spring + Thymeleaf project?

          Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents