# Aligning an equation graph with an ybar graph

I am so desperately trying to align an equation graph (which consists of a bunch of sine waves) with a ybar graphs places on its right that represents its Fourier transformation. I have used the subfloat environment in order to have two distinct figures which I could then reference and caption individually. The problem that soon arose is that I can't seem to figure out how to align these two graphs properly, and I believe that the problem comes from the fact that the ybar graph has a different structure and layout than the normal graph. I have tried hiding the tick marks of the bar graph but that didn't fix the problem. How can I solve this? Thanks in advance!

\begin{figure}[H]
\centering
\subfloat[][]{
\begin{tikzpicture}
\begin{axis}[
ymajorgrids=true,
grid style=dashed,tick pos=left,width=9cm,height=8cm]
\end{axis}
\end{tikzpicture}
}
\subfloat[][]{
\begin{tikzpicture}
\begin{axis}[ybar,xmin=0,xmax=1000,tick pos=left, width=9cm,height=8cm]
coordinates{(200,6) (400,4) (600,3) (800,2)};
\end{axis}
\end{tikzpicture}
}
\end{figure} • Consider accepting the provided answer! May 28, 2021 at 2:38

Here is a way, using the floatrow package:

\documentclass{article}
\usepackage[utf8]{inputenc} %
\usepackage{geometry}
\usepackage{caption, subcaption, floatrow, tikz, pgfplots}
\pgfplotsset{compat=1.18}

\begin{document}

\begin{figure}[!ht]
\ffigbox{%
\begin{subfloatrow}
\ffigbox[\FBwidth]{\caption{}\label{fig:1}}
{\begin{tikzpicture}
\begin{axis}[
ymajorgrids=true,
grid style=dashed,tick pos=left,width=9cm,height=8cm]
\end{axis}
\end{tikzpicture}}
\ffigbox[\FBwidth]{\caption{}\label{fig:2}}
{\begin{tikzpicture}
\begin{axis}[ybar,xmin=0,xmax=1000,tick pos=left, width=9cm,height=8cm]
coordinates{(200,6) (400,4) (600,3) (800,2)};
\end{axis}
\end{tikzpicture}}
\end{subfloatrow}}
{\caption{Sine waves and their Fourier transforms}\label{fig}}
\end{figure}

\end{document} • +1: Never heard of the floatrow package! I would have tried something with scale only axis as a first guess. May 25, 2021 at 16:15
• @Dr.ManuelKuehner: It cooperates with caption, but has a drawback: one cannot load the float package (however, I believe it has similar functionalities). May 25, 2021 at 16:30