Seite 1 von 1

Foto hinter Diagramm platzieren

Verfasst: Mo 7. Nov 2016, 19:27
von Vaschan
Hallo,

ich es möglich ein Foto als Hintergrund hinter ein Diagramm zu setzen?

So wie das bei Excel mit Füllung und dann mit der Option Bild- oder Texturfüllung möglich ist.
\documentclass[12pt,titlepage,a4paper]{report} 

\usepackage[pdftex]{graphicx} 
\usepackage{pgfplots}

\begin{document} 

	\begin{tikzpicture}
		\begin{axis}
			\addplot coordinates {( 338.1, 266.45 )( 169.1, 143.43 )( 84.5, 64.80 )( 42.3, 34.19 )( 21.1, 9.47 )};

		\end{axis}
	\end{tikzpicture}
\end{document}
Also hier statt weiß eine .jpg-Datei

Verfasst: Mo 7. Nov 2016, 22:17
von esdd
pgfplots lädt sowieso graphicx und die Option pdftex lässt Du besser ganz weg. Dafür sollte man durch Setzen von compat immer eine Kompatibilitätseinstellung für pgfplots vornehmen, sonst wird automatisch Kompatibilität zu pre1.3 hergestellt.

Mir erschließt sich nicht, warum man hinter ein Diagramm noch ein Bild setzen soll, aber möglich ist das natürlich. Wie genau hängt u.a. davon ab, welche Optionen man sonst noch für die axis setzt und ob man layer verwendet.

Eine einfache Möglichkeit für Dein Beispiel wäre
\documentclass[12pt,titlepage,a4paper]{report} 
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document} 
\begin{tikzpicture} 
  \begin{axis} 
    \addplot coordinates {( 338.1, 266.45 )( 169.1, 143.43 )( 84.5, 64.80 )( 42.3, 34.19 )( 21.1, 9.47 )}; 
    \node at (current axis.center){%
      \includegraphics[
        width=\dimexpr\axisdefaultwidth-45pt\relax,
        height=\dimexpr\axisdefaultheight-45pt\relax
     ]{example-image}};
  \end{axis} 
\end{tikzpicture} 
\end{document}