How to place 7 subfigures properly aligned?

Since you are changing the margins, it helps to put everything into one minipage or \parbox with the right width. I used a \parbox since it doesn't change \textwidth. Using \rlap, \llap and \makebox avoids overfull \hbox warnings.

I noticed that you stopped just short of the marginpar area, so that is where I started my \llap.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{subcaption}
\usepackage[dvipsnames]{xcolor}
\usepackage[showframe]{geometry}
    \geometry{a4paper}

\begin{document}
    \begin{figure}[htbp]
    \hspace*{\fill}\rlap{\hspace{\dimexpr \marginparsep-4pt}% stop 4pt short of marginpar area
      \llap{\parbox{\dimexpr 1.05\textwidth+4em+1pt}{% set new margins plus 1pt roudoff
        \centering
        \makebox[0.35\textwidth]{\subfloat[Pregunta 1\label{q1}]{%
            \includegraphics[scale=0.45]{example-image-a}
        }}%
        \hspace{2em}%
        \makebox[0.35\textwidth]{\subfloat[Pregunta 2\label{q2}]{
            \includegraphics[scale=0.45]{example-image-a}
        }}%
        \hspace{2em}%
        \makebox[0.35\textwidth]{\subfloat[Pregunta 3\label{q3}]{
            \includegraphics[scale=0.45]{example-image-a}
        }}
        \par\medskip
% I was curious how this would work
        \subfloat[Pregunta 4\label{q4}]{\includegraphics[scale=0.45]{example-image-a}}\hfill
        \subfloat[Pregunta 5\label{q5}]{\includegraphics[scale=0.45]{example-image-a}}\hfill
        \subfloat[Pregunta 6\label{q6}]{\includegraphics[scale=0.45]{example-image-a}}\par\medskip

        \subfloat[Pregunta 7]{
            \label{q7}
            \includegraphics[scale=0.45]{example-image-a}
            }
        \caption{Diagramas de barras del test post-experimento}
    }}}
    \end{figure}
\end{document}

  • minipages are not needed
  • text width can be locally enlarged by use of \adjustwidth macro, defined in the changepage package, however, in the first you need to ask yourself, is this is really needed
  • determining image size with width in Gin keys enables simple possibility to make all image narrowed that can be fit in the \textwidth (see second example)
\documentclass{article}
\usepackage[showframe,  % in real document remove this option
            a4paper]{geometry}

%\usepackage[utf8]{inputenc} this is default encoding
\usepackage[spanish]{babel}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage[strict]{changepage}

\begin{document}
    \begin{figure}[htbp]
    \setkeys{Gin}{width=0.32\linewidth} % <---
\begin{adjustwidth}{}{-\dimexpr\marginparsep+\marginparwidth}   % <--- locally enlarge text width 
  \centering
  \subfloat[][Pregunta 1    \label{q1}]{\includegraphics{example-image-a}}\hfill
  \subfloat[][Pregunta 2    \label{q2}]{\includegraphics{example-image-b}}\hfill
  \subfloat[][Pregunta 3    \label{q2}]{\includegraphics{example-image-c}}
  
\medskip
  \subfloat[][Pregunta 4    \label{q4}]{\includegraphics{example-image-a}}\hfill
  \subfloat[][Pregunta 5    \label{q5}]{\includegraphics{example-image-b}}\hfill
  \subfloat[][Pregunta 6    \label{q6}]{\includegraphics{example-image-c}}

\medskip
  \subfloat[][Pregunta 7    \label{q7}]{\includegraphics{example-image-duck}}

\caption{Diagramas de barras del test post-experimento}
\label{fig:q}
\end{adjustwidth}
    \end{figure}
\end{document}

enter image description here

(grey lines indicate page layout)

In the case, that you are satisfied with with the narrower images, you only need in ABove MWE remove \adjustwidth anviromant and set Gin norrower images. For example:

\documentclass{article}
\usepackage[a4paper]{geometry}
\usepackage[spanish]{babel}
\usepackage{graphicx}
\usepackage{subfig}

\begin{document}
    \begin{figure}[htbp]
    \setkeys{Gin}{width=0.32\textwidth} % <---
  \centering
\subfloat[][Pregunta 1    \label{q1}]{\includegraphics{example-image-a}}\hfill
\subfloat[][Pregunta 2    \label{q2}]{\includegraphics{example-image-b}}\hfill
\subfloat[][Pregunta 3    \label{q2}]{\includegraphics{example-image-c}}

\medskip
\subfloat[][Pregunta 4    \label{q4}]{\includegraphics{example-image-a}}\hfill
\subfloat[][Pregunta 5    \label{q5}]{\includegraphics{example-image-b}}\hfill
\subfloat[][Pregunta 6    \label{q6}]{\includegraphics{example-image-c}}

\medskip
\subfloat[][Pregunta 7    \label{q7}]{\includegraphics{example-image-duck}}

\caption{Diagramas de barras del test post-experimento}
\label{fig:q}
    \end{figure}
\end{document}

enter image description here


I see no reason for going beyond the margins. Don't use scale, but set the width instead. And don't forget to avoid unwanted spaces.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{subfig}
\usepackage[dvipsnames]{xcolor}
\usepackage{geometry}

\geometry{a4paper}

\begin{document}

\begin{figure}[htbp]
\centering

\subfloat[Pregunta 1]{% <--- important
  \label{q1}% <--- important
  \includegraphics[width=0.32\textwidth]{example-image-a}% <--- important
}\hfill
\subfloat[Pregunta 2]{%
  \label{q2}%
  \includegraphics[width=0.32\textwidth]{example-image-a}%
}\hfill
\subfloat[Pregunta 3]{%
  \label{q3}%
  \includegraphics[width=0.32\textwidth]{example-image-a}%
}

\medskip

\subfloat[Pregunta 4]{%
  \label{q4}%
  \includegraphics[width=0.32\textwidth]{example-image-a}%
}\hfill
\subfloat[Pregunta 5]{%
  \label{q5}%
  \includegraphics[width=0.32\textwidth]{example-image-a}%
}\hfill
\subfloat[Pregunta 6]{%
  \label{q6}%
  \includegraphics[width=0.32\textwidth]{example-image-a}%
}

\medskip

\subfloat[Pregunta 7]{%
  \label{q7}%
  \includegraphics[width=0.32\textwidth]{example-image-a}%
}

\caption{Diagramas de barras del test post-experimento}

\end{figure}

\end{document}

enter image description here

If you have eight subfloats, the last pair can be input as

\subfloat[Pregunta 7]{%
  \label{q7}%
  \includegraphics[width=0.32\textwidth]{example-image-a}%
}\hspace{0.02\textwidth}%
\subfloat[Pregunta 8]{%
  \label{q7}%
  \includegraphics[width=0.32\textwidth]{example-image-a}%
}

This is because the space between images in the first two rows is 0.02\textwidth.

enter image description here

If you really want to go past the margins, you can do it in an automatic way by using \leftskip and \rightskip set to negative values and setting a parameter equal to the text width plus the “oversize”.

For the example I added the showframe option to \geometry in order to see the text block boundaries.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{subfig}
\usepackage[dvipsnames]{xcolor}
\usepackage{geometry}

\geometry{a4paper,showframe}

\newlength{\oversized}

\begin{document}

\begin{figure}[htbp]
\centering
\addtolength{\leftskip}{-3em}
\addtolength{\rightskip}{-3em}
\setlength{\oversized}{\textwidth}
\addtolength{\oversized}{6em}

\subfloat[Pregunta 1]{%
  \label{q1}%
  \includegraphics[width=0.32\oversized]{example-image-a}%
}\hfill
\subfloat[Pregunta 2]{%
  \label{q2}%
  \includegraphics[width=0.32\oversized]{example-image-a}%
}\hfill
\subfloat[Pregunta 3]{%
  \label{q3}%
  \includegraphics[width=0.32\oversized]{example-image-a}%
}

\medskip

\subfloat[Pregunta 4]{%
  \label{q4}%
  \includegraphics[width=0.32\oversized]{example-image-a}%
}\hfill
\subfloat[Pregunta 5]{%
  \label{q5}%
  \includegraphics[width=0.32\oversized]{example-image-a}%
}\hfill
\subfloat[Pregunta 6]{%
  \label{q6}%
  \includegraphics[width=0.32\oversized]{example-image-a}%
}

\medskip

\subfloat[Pregunta 7]{%
  \label{q7}%
  \includegraphics[width=0.32\oversized]{example-image-a}%
}

\caption{Diagramas de barras del test post-experimento}

\end{figure}

\end{document}

enter image description here