Foto hinter Diagramm platzieren

Tabellen und Grafiken erstellen und anordnen


Vaschan
Forum-Fortgeschrittener
Forum-Fortgeschrittener
Beiträge: 68
Registriert: So 8. Mai 2016, 12:35

Foto hinter Diagramm platzieren

Beitrag 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

esdd
Forum-Meister
Forum-Meister
Beiträge: 2561
Registriert: So 7. Feb 2010, 16:36

Beitrag 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}

Antworten