[Tex/LaTex] Add labels to tikzpicture plots

tikz-pgf

How do you add labels like A and B to the two plots below?

enter image description here

I tried some variations of \node (A) at ([xshift=-1.3cm, yshift=1cm]group c1r1.north west) {\color{black} (A)};, but this didn't work, mainly because I am not using a group plots environment. Here is my code:

\documentclass[]{article}
    \usepackage{pgfplots, alphalph}
    \usepgfplotslibrary{groupplots}
    \pagenumbering{gobble}

\begin{document}

\begin{figure}
\hspace*{-3.5cm}
\centering
\begin{minipage}{.5\textwidth}
  \centering
  \begin{tikzpicture}
\begin{axis}[ 
    title={My title},
    axis lines=middle,
    axis line style={->},
    ylabel near ticks,
    xlabel near ticks,
    scaled y ticks = false,
    yticklabel style={/pgf/number format/fixed},
    xlabel={x-label},
    ylabel={y-label}]


\end{axis} 
\end{tikzpicture}
\end{minipage}%
\begin{minipage}{1.3\textwidth}
  \centering
  \begin{tikzpicture}
\begin{axis}[ 
    title={My title},
    axis lines=middle,
    axis line style={->},
    ylabel near ticks,
    xlabel near ticks,
    scaled y ticks = false,
    yticklabel style={/pgf/number format/fixed},
    xlabel={x-label},
    ylabel={y-label}]
\end{axis} 
\end{tikzpicture}
\end{minipage}
\end{figure}

\end{document}

Best Answer

You want to put A and B at the upper right corner of the plots?

Then the node current bounding box can be used. This method works independently from package pgfplots.

\documentclass[]{article}
    \usepackage{pgfplots, alphalph}
    \usepgfplotslibrary{groupplots}
    \pagenumbering{gobble}

\begin{document}

\begin{figure}
\hspace*{-3.5cm}
\centering
\begin{minipage}{.5\textwidth}
  \centering
  \begin{tikzpicture}
\begin{axis}[
    title={My title},
    axis lines=middle,
    axis line style={->},
    ylabel near ticks,
    xlabel near ticks,
    scaled y ticks = false,
    yticklabel style={/pgf/number format/fixed},
    xlabel={x-label},
    ylabel={y-label}]
\end{axis}
  \node[below right]
    at (current bounding box.north west) {A};
\end{tikzpicture}
\end{minipage}%
\begin{minipage}{1.3\textwidth}
  \centering
  \begin{tikzpicture}
\begin{axis}[
    title={My title},
    axis lines=middle,
    axis line style={->},
    ylabel near ticks,
    xlabel near ticks,
    scaled y ticks = false,
    yticklabel style={/pgf/number format/fixed},
    xlabel={x-label},
    ylabel={y-label}]
\end{axis}
  \node[below right]
    at (current bounding box.north west) {B};
\end{tikzpicture}
\end{minipage}
\end{figure}

\end{document}

Result

Related Question