# Add subfloat label (a) at the bottom left corner of a pgfplot figure

I'm wondering what is the cleanest and simplest way to add a subfloat label (like (a)) at the bottom left of a tikzpicture or pgfplot. I generally export plots from matlab with matlab2tikz with this command matlab2tikz('Figure_name.tikz', 'height', '\figureheight', 'width', '\figurewidth');, but I don't mind manually editing the resulting file, as I anyhow need to make some cosmetic changes.

There are already some posts like Reference pgfplots' groupplot with subcaption or Placing a label in specific corner of the chart, but the location differs from what I would like to achieve.

Similarly, in Put subfigure labels inside figures using subfig package, there is a small macro defined to place the label exactly where I want if the code is modified into the following:

\newcommand{\subfigimg}[3][,]{%
\setbox1=\hbox{\includegraphics[#1]{#3}}% Store image in box
\leavevmode\rlap{\usebox1}% Print image
\rlap{\hspace*{5pt}\raisebox{.5\baselineskip}{\sffamily\footnotesize{#2}}}% Print label
\phantom{\usebox1}% Insert appropriate spacing
}


When using a tikzpicture I modified the previous macro into

\newcommand{\modsubfigimg}[2][,]{%
\setbox1=\hbox{#1}% Store image in box
\leavevmode\rlap{\usebox1}% Print image
\rlap{\hspace*{5pt}\raisebox{.5\baselineskip}{\small{#2}}}% Print label
\phantom{\usebox1}% Insert appropriate spacing
}


but the result is not satisfactory visually.

Right now I'm using the following code snippet (with \tikzexternalize, but that's not relevant here), and the alignment inside each minipage is messed up (\centering can't be used for instance).

\begin{minipage}[b]{.5\textwidth}
\tikzsetnextfilename{PD-PWM_carrier_band}%
\modsubfigimg[(a)]{\input{gfx/PDPWM_carrier_band.tikz}}
\end{minipage}%
\begin{minipage}[b]{.5\textwidth}
\tikzsetnextfilename{PS-PWM_carrier_band}%
\modsubfigimg[(b)]{\input{gfx/PSPWM_carrier_band.tikz}}
\end{minipage}


Something like this?

\documentclass{standalone}
\usepackage{pgfplots}

\newcounter{subfig}[figure]
\renewcommand{\thesubfig}{\alph{subfig}}

\begin{document}

\begin{tikzpicture}
\begin{axis}

• It does well the job, if I modify below left to above right and move the \stepcounter{subfig} when using \tikzexternalize. – s__C Oct 26 '16 at 14:33