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:

  \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

  \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).


Something like this?




\addplot coordinates {(0,0) (1,10)}; 
\node[below left] at (current bounding box.south west) {\stepcounter{subfig}(\thesubfig)};



  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.