1

Using the following code, as a part of a more complicated drawing, how to move the included graphic vertically in relation to the node, keeping it on the background layer.

\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{backgrounds}
\begin{document}
\begin{frame}[t]
\frametitle{}
\begin{minipage}[c]{.9\textwidth}
\begin{center}
\vskip 1.4cm
\begin{tikzpicture}[scale=.7, transform shape]
\begin{scope}[xshift=0cm, yshift=0cm]
\draw [thick] (0,0) -- (9,0) -- (9,7.14);
\draw [thick] (0,0) -- (0,7.14)  node[xshift=.6cm, yshift=.48cm]{percent} -- (9,7.14);
\end{scope}
\node [black] at (1.6,5) (euro){\scriptsize Euro area} ([shift={(-90.:2.48cm)}]euro.center) node {\scriptsize United States};
\begin{scope}[on background layer]
\hspace {.16cm}
\includegraphics[height=3.2cm,keepaspectratio]{./13-CrossSectionTimeSeriesData.png}
\end{scope}
\end{tikzpicture}
\end{center}
\end{minipage}
\end{frame}
\end{document}

This code producedenter image description here

I need it to beenter image description here

1 Answer 1

4

You should not just use \includegraphics "naked" in the tikzpicture but put it in a node. This also solves the problem of positioning the graphics.

\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{backgrounds}
\begin{document}
\begin{frame}[t]
\frametitle{}
\begin{minipage}[c]{.9\textwidth}
\centering
\begin{tikzpicture}[scale=.7, transform shape]
\path (0,10);
\begin{scope}[xshift=0cm, yshift=0cm]
\draw [thick] (0,0) -- (9,0) -- (9,7.14);
\draw [thick] (0,0) -- (0,7.14)  node[xshift=.6cm, yshift=.48cm]{percent} -- (9,7.14);
\end{scope}
\node [black] at (1.6,5) (euro){\scriptsize Euro area} 
([shift={(-90.:2.48cm)}]euro.center) node {\scriptsize United States};
\begin{scope}[on background layer]
\node[anchor=west] at ([shift={(-0.7cm,-1cm)}]euro.west) 
{\includegraphics[height=3.2cm,keepaspectratio]{./13-CrossSectionTimeSeriesData.png}};
\end{scope}
\end{tikzpicture}
\end{minipage}
\end{frame}
\end{document}

enter image description here

1
  • Thank you very much for your answer
    – Hany
    Oct 8, 2019 at 6:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.