# Beamer theme Metropolis changes TikZ draw

I am having trouble adding a TikZ graphic to my Beamer presentation which uses the theme Metropolis. Here is an example of the issue:

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}

%\usetheme{metropolis}

\pgfplotsset{compat=1.18}

\begin{document}

\begin{frame}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
view = {135}{20},
xlabel=$x$,
ylabel=$y$,
zlabel=$z$,
xmin=-1, xmax=1,
ymin=-1, ymax=1,
zmin=0, zmax=1,
]
\draw (0, 1, 0) -- (1, 1, 1);
\end{axis}
\end{tikzpicture}
\end{center}
\end{frame}

\end{document}


This code does what I want, but uncommenting the line \usetheme{metropolis} changes the graphic and makes the line shorter. (I don't think it's invisible, just a very small length.) How can I get the desired image while still using the Metropolis theme?

The compile log shows PGFPlots

Package pgfplots notification 'compat/show suggested version=true': you might b enefit from \pgfplotsset{compat=1.18} (current compat level: 1.9).

Even though you have \pgfplotsset{compat=1.18}. The 1.9 level is hardcoded in the metropolis theme.

PGFPlots introduced axis cs: as the default coordinate system in version 1.11. One way is to keep using version 1.9 and give the coordinate system explicitly like this:

\draw (axis cs:0, 1, 0) -- (axis cs:1, 1, 1);


an other probably better way is to move \pgfplotsset{compat=1.18} inside \begin{document} like this:

\documentclass{beamer}
\usepackage{pgfplots}
\usetheme{metropolis}
\begin{document}
\pgfplotsset{compat=1.18}
\begin{frame}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
view = {135}{20},
xlabel=$x$,
ylabel=$y$,
zlabel=$z$,
xmin=-1, xmax=1,
ymin=-1, ymax=1,
zmin=0, zmax=1,
]
\draw (0, 1, 0) -- (1, 1, 1);
\end{axis}
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}


-or you could edit line 913 in the theme to correct the version.