2

I'm trying to add an external image as a skewed plane in a 3D plot. The skewing should be done with pgfplots.

The desired output looks like this: Desired output

The minimal working example inserts the unskewed version of the image as shown below.

MWO output

If it is not possible to skew the image with pgfplots, I could also save the intensity data for each y and z coordinate. How would it be possible to add the data from a table then?

\documentclass{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
enlargelimits=false,
axis on top,
axis equal image,
xmin=0,xmax=4,
ymin=-1,ymax=1,
zmin=-1,zmax=1,
xlabel=$x$,ylabel=$y$,zlabel=$z$,
view={-20}{30},
xtick={0, 3},
]
\addplot3 graphics [
xmin=3,xmax=3,
ymin=-1,ymax=1,
zmin=-1,zmax=1,
] {test_img.jpg};
\end{axis}
\end{tikzpicture}
\end{document}

1 Answer 1

3

I am not sure if pgfplots supports that. If so, then through the option points, which I left but commented in my code because I couldn't make the picture transform. However. it is possible to use the 3d library to transform and place the picture.

\documentclass{standalone}
\usepackage{pgfplots}
\usetikzlibrary{3d,calc}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
enlargelimits=false,
axis on top,
axis equal image,
xmin=0,xmax=4,
ymin=-1,ymax=1,
zmin=-1,zmax=1,
xlabel=$x$,ylabel=$y$,zlabel=$z$,
view={-20}{30},
xtick={0, 3},
]
\path (axis cs:0,0,0) coordinate (O) (axis cs:1,0,0) coordinate (X)  
(axis cs:0,1,0) coordinate (Y) (axis cs:0,0,1) coordinate (Z)
 (axis cs:3,0,0) coordinate (P)  ;
% \addplot3 graphics [points={
% (3,-1,-1) => (0,0)
% (3,1,1) => (8,5)
% (3,-1,1) => (0,5)
% (3,1,-1) => (8,0) 
% (3,0,0) => (4,2.5) 
% }
% ] {example-image-duck};
\end{axis}
 \begin{scope}[x={($(X)-(O)$)},y={($(Y)-(O)$)},z={($(Z)-(O)$)},
    canvas is yz plane at x=0,transform shape]
  \path (P) node{\includegraphics[width=2cm,height=2cm]{example-image-duck}};
 \end{scope}
\end{tikzpicture}
\end{document}

enter image description here

You can have it inside the axis environment as well.

\documentclass{standalone}
\usepackage{pgfplots}
\usetikzlibrary{3d,calc}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
enlargelimits=false,
axis on top,
axis equal image,
xmin=0,xmax=4,
ymin=-1,ymax=1,
zmin=-1,zmax=1,
xlabel=$x$,ylabel=$y$,zlabel=$z$,
view={-20}{30},
xtick={0, 3},
]
\path (axis cs:0,0,0) coordinate (O) (axis cs:1,0,0) coordinate (X)  
(axis cs:0,1,0) coordinate (Y) (axis cs:0,0,1) coordinate (Z)
 (axis cs:3,0,0) coordinate (P)  
 [x={($(X)-(O)$)},y={($(Y)-(O)$)},z={($(Z)-(O)$)},
    canvas is yz plane at x=0,transform shape]
   (P) node{\includegraphics[width=2cm,height=2cm]{example-image-duck}};
\end{axis}
\end{tikzpicture}
\end{document}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .