6

i wanted to know if it possible to have the plot's title below the x-axis instead of above. i attach the plot that i've done:

enter image description here

and the code for the axis that i used for the graph on the left:

 \begin{axis}[xmin=0, xmax=60,axis y line*=left,ymin=9.79,ymax=9.87, xlabel=
{Tempo [ore]}, ylabel={Pressione [bar]},title=\textbf{a)} {$P_{media}$ VS 
$T_{media}$},legend style={draw=none, at={(1,.0)},anchor=south east}]

Thank you

  • 1
    Try add title style={at={(0.5,0)},anchor=north,yshift=-0.1} between axis options. – Zarko Feb 26 '16 at 9:36
  • 2
    I wouldn't use the title as a caption. Rather use \subfig or similar, you can also have labels and references – mirkom Feb 26 '16 at 10:48
  • If you use \begin{axis}[name=myname] you can use anchor points like (myname.south) to attach text nodes (after \end{axis}). – John Kormylo Feb 26 '16 at 17:27
11

Lets summarize and extend above comments. The first and the last (from John Kormylo and mine) propose solution to place graph title as part of graph, the second propose to omit title as part of graph and determine it in subcaption environment:

Solution 1:

\begin{tikzpicture}
 \begin{axis}[
 ...
 title style={at={(0.5,0)},anchor=north,yshift=-0.1},
 title = ....,
                ]
 ...
 \end{axis}
 \end{tikzpicture}

Solution 2:

\begin{tikzpicture}
 \begin{axis}[
 name=mygraph, % or whatewer
                ]
 ...
 \end{axis}
 \node[anchor=north] at (mygraph.south) { ... title ...};
 \end{tikzpicture}

Solution 3a:

\documentclass{...}
\usepackage{subcaption}

\begin{document}
\begin{figure}[h]\centering
    \begin{subcaption}{<width}
\begin{tikzpicture}
 ...
 \end{tikzpicture}
\caption{ ... title ...}
\label{subfig:1}
    \end{subcaption}
\hfil
\begin{tikzpicture}
 ...
 \end{tikzpicture}
\caption{ ... title ...}
\label{subfig:2}
    \end{subcaption}
\caption{figure caption}
\label{fig:...}
\end{figure}
\end{document}

Solution 3b: In this last solution you also can use subfig package instead subcaption and its subfloat environment:

\begin{document}
\begin{figure}[h]\centering
    \subfloat[ ... title ... \label{...}]
    {
\begin{tikzpicture}
 ...
 \end{tikzpicture}
    }
\hfil
    \subfloat[ ... title ... \label{...}]
    {
\begin{tikzpicture}
 ...
 \end{tikzpicture}
    }
\caption{figure caption}
\label{fig:...}
\end{figure}
\end{document}
  • thank you very much for your clearness. Definetly i've used the 3b option with 'subfig' package and it works! – Paolo Orsatti Feb 27 '16 at 14:19

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.