8

I have almost managed,

With this code:

\begin{figure}[htb]
\hspace*{-5cm}
\begin{minipage}{0.5cm}
\rotatebox{90}{\textcolor{red}{$y$-axis label}}
\end{minipage}%
\begin{minipage}{\dimexpr\linewidth-2.50cm\relax}%
\begin{minipage}{0.5cm}
\rotatebox{90}{\textcolor{red}{$y$-axis label}}
\end{minipage}%
  \raisebox{\dimexpr-.5\height-1em}{\includegraphics[scale=0.225]{MagneticTransport.pdf}}
\qquad
  \raisebox{\dimexpr-.5\height-1em}{\includegraphics[scale=0.25]{aspectratio.pdf}}

  \vspace*{0.1cm}\hspace*{2.0cm}\textcolor{red}{$x$-axis label}
   \vspace*{0.1cm}\hspace*{5.0cm}\textcolor{red}{$x$-axis label}
\end{minipage}%
\end{figure}

I get this:enter image description here

I would like:

  • To have the other 'y-label' next to the second graph, and
  • if possible, have the 'x-label' and 'y-label' centred underneath (on the side) of the plots.
0

1 Answer 1

12

A solution with tikzpicture:

\documentclass{article}
\usepackage{tikz}
\usepackage{graphicx}
\usetikzlibrary{positioning}


\begin{document}

\begin{figure}[htb]
\begin{minipage}{0.4\textwidth}
\begin{tikzpicture}
  \node (img)  {\includegraphics[scale=0.225]{example-image}};
  \node[below=of img, node distance=0cm, yshift=1cm,font=\color{red}] {x-axis};
  \node[left=of img, node distance=0cm, rotate=90, anchor=center,yshift=-0.7cm,font=\color{red}] {y-axis};
 \end{tikzpicture}
\end{minipage}%
\begin{minipage}{0.4\textwidth}
\begin{tikzpicture}
  \node (img)  {\includegraphics[scale=0.225]{example-image}};
  \node[below=of img, node distance=0cm, yshift=1cm,font=\color{red}] {x-axis};
  \node[left=of img, node distance=0cm, rotate=90, anchor=center,yshift=-0.7cm,font=\color{red}] {y-axis};
\end{tikzpicture}
\end{minipage}%
\end{figure}
\end{document}

enter image description here

And without minipages:

\begin{document}

\begin{figure}[htb]
\begin{tikzpicture}
  \node (img1)  {\includegraphics[scale=0.225]{example-image}};
  \node[below=of img1, node distance=0cm, yshift=1cm,font=\color{red}] {x-axis};
  \node[left=of img1, node distance=0cm, rotate=90, anchor=center,yshift=-0.7cm,font=\color{red}] {y-axis};
  \node[right=of img1,yshift=0.1cm] (img2)  {\includegraphics[scale=0.25]{example-image}};
  \node[below=of img2, node distance=0cm, yshift=1cm,font=\color{red}] {x-axis};
  \node[left=of img2, node distance=0cm, rotate=90, anchor=center,yshift=-0.7cm,font=\color{red}] {y-axis};
\end{tikzpicture}
\end{figure}
\end{document}

I had to replace your pdf files with the example-image of graphicx. Please try to provide a MWE in future questions.

3
  • I think it should be "left of=img1" rather than "left=of img1", etc. Also, the anchor seems superfluous Commented Sep 26, 2017 at 21:40
  • @JoelWallman [S G speaking] A minor indication with respect to Joel Wallman comment, the syntax "left = of Img1" is correct and required for right placements.
    – user156344
    Commented Mar 16, 2019 at 12:14
  • What would you do for a 4x4 panel? And you only want one y label accross both blots and one common x label, large accross the bottom of both plots? Commented May 3, 2023 at 6:58

You must log in to answer this question.

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