2

I'm including two images with pgfplots plot graphics. They have the same height (693px) but different width (883px and 1023px). However, I can't manage to get them drawn with the same height.

How can I solve this? I've tried adding height here and there or reading through the pgfplots chapters, but I'm sure I'm missing something obvious.

enter image description here

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[enlargelimits=false,axis equal image]
        \addplot graphics [
            xmin=0,xmax=38.225,ymin=0,ymax=30,
            includegraphics={draft}
        ] {883x693.png}; 
    \end{axis}
\begin{axis}[enlargelimits=false,axis equal image,xshift=8cm]
    \addplot graphics [
        xmin=0,xmax=44.28,ymin=0,ymax=30,
        includegraphics={draft}
    ] {1023x693.png};
\end{axis}

\end{tikzpicture} \end{document}

(I'd prefer the drawn image to have the same number of pixels as the PNG files, but I believe that's outside of pgfplots' scope?)

Anna
  • 811

1 Answers1

2
\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{calc}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
name=image1,
width=883px, height=693px, scale only axis,
enlargelimits=false,
]
\addplot graphics[xmin=0, xmax=38.225, ymin=0, ymax=30] {example-image}; 
\end{axis}
\begin{axis}[
name=image2, at={($(image1.south east)+(1cm,0)$)},
width=1023px, height=693px, scale only axis,
enlargelimits=false,
]
\addplot graphics[xmin=0, xmax=44.28, ymin=0, ymax=30] {example-image}; 
\end{axis}
\end{tikzpicture}
\end{document}

Two gray example images within graphs

The px unit can be found here: https://tex.stackexchange.com/a/41371/8650

To test the unit, this code can be used:

\documentclass[tikz, border=1cm]{standalone}
\begin{document}
\begin{tikzpicture}
\node[anchor=south west, draw, inner sep=0pt] {\includegraphics{anyimage.jpg}}; %inserts the image unscaled
\draw[red] (0,0) -- (468px,450px); %insert known size of image
\end{tikzpicture}
\end{document}