使用以下代码,作为更复杂绘图的一部分,如何相对于节点垂直移动包含的图形,并将其保持在背景层上。
\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}
答案1
您不应该只使用\includegraphics
“naked”,tikzpicture
而应该将其放在节点中。这也解决了图形定位的问题。
\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}