# How can I embed an external image within the TikZ environment in the axis positions?

From How can I embed an external image within a tikzpicture environment? I can see that \includegraphics can be used within a TikZ environment using \node.

However, my tikzpicture includes an axis environment (from a plot generated in matlab and translated to TikZ) and I wish to position the node based on this axis rather than the picture position.

Is it possible to be done?

Here is simplified version of my code. Right now to position my figure I'm using \node[inner sep=0pt] (test) at (14,10), which from what I understand refers to the figure position, not the axis position.

\begin{tikzpicture}
\begin{axis}[%
xmin=0,
xmax=5,
tick align=outside,
xlabel={x},
ymin=-11,
ymax=0.5,
ylabel={y},
zmin=0,
zmax=20,
zlabel={z},
view={-57.4}{14.4},
axis background/.style={fill=white},
legend style={at={(1.03,1)}, anchor=north west, legend cell align=left, align=left, draw=white!15!black}
]
table[row sep=crcr] {%
0   0   0\\
4   0.03    17\\
};
\node[inner sep=0pt] (test) at (14,10)
{\includegraphics[width=.25\textwidth]{harmonicfit}};
\end{axis}
\end{tikzpicture}%

• Welcome to TeX-SE! You can always use tex.stackexchange.com/a/9562/121799
– user121799
Feb 27, 2019 at 15:33
• My case is of a 3d plot, does that still apply? Feb 27, 2019 at 15:37
• Could you please provide an explicit example? Is your embedding picture a 3d axis in which you want to include an external graphics? Then you can just use the axis coordinates. (If you want to embed the picture in a 3d-like fashion, i.e. using orthographic projections, you could use the 3d library along with transform shape.)
– user121799
Feb 27, 2019 at 15:41
• I edited the question to add the code Mar 1, 2019 at 10:48