2

Hello I want to have Under each plot (subgroup plot) its caption or label, so I can also reference it in my document. Here in my example I used (a), (b), (c) I can keep them but they are not well aligned, and how to get them referenced in the text. Thanks enter image description here enter image description here

\documentclass[french,12pt,oneside,openright]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[a4paper]{geometry}
\usepackage[french]{babel} %langue francaise
\usepackage{graphicx,xcolor} %insertion d'images
\usepackage{titlesec}
\graphicspath{{Annexes/images/}} %directory of the images
\usepackage{lipsum} %paragraphes prédéfinis
\usepackage[sonny]{fncychap}
\usepackage{usnomencl}%pour la nomenclature
\usepackage{pgfplots}
\usepackage{titlesec, blindtext, color}
\definecolor{gray75}{gray}{0.75}
\newcommand{\hsp}{\hspace{20pt}}
\titleformat{\chapter}[hang]{\Huge\bfseries}{\thechapter\hsp\textcolor{gray75}{|}\hsp}{0pt}{\Huge\bfseries}
\usepackage{multirow,array}
\usepackage{siunitx}
\usepackage{tocloft} %costumize the list of...
\usepackage{amssymb}
\usepackage{amsmath} %add mathematic symbols
\usepackage{caption}  %for tables andfigures
\usepackage{subcaption} %add many sub (tables/figures) with the same caption
\usepackage{chemfig}
\renewcommand*\printatom[1]{\ensuremath{\mathsf{#1}}}
\usepackage{tikz}
\usepackage{hyperref} %add a hyperlink to the contents
\usepackage{setspace}
\usepgfplotslibrary{groupplots}
\usetikzlibrary{matrix,positioning}
\begin{document}
    \chapter{BJH}
 \pagebreak
\center{\huge{\hspace{2 cm}BJH}}\\
~\\
\begin{tikzpicture}
    \begin{groupplot}[group style={group size= 2 by 3,horizontal sep =1.5cm,vertical sep =1.5cm},height=6.5cm,width=8cm]

       \nextgroupplot[legend pos=north east,
        legend style={draw=none},
        y tick label style={anchor=east},       
        xticklabel=\empty,
        ytick pos=left,
        scaled ticks=true,      
        xmin=0,
        xmax=110,
        xlabel=(1),         
        ]
                \addlegendimage{empty legend};
                \addplot[red, mark=+] table{Annexes/resultats/BET/GRAPbjh1.dat};\label{plotsplot1}
                \addlegendentry{Graphite}[15 pt];               
                \coordinate (top) at (rel axis cs:0,1);% coordinate at top of the first plot            
        \nextgroupplot[legend pos=north east,
        legend style={draw=none},
        scaled ticks=false, %enlever le.10^-5 !!!!!!!!!!!!
        yticklabel pos=left,        
        ytick pos=left,
        scaled ticks=true,
        y tick label style={anchor=east},       
        xmin=0,
        xmax=140,
        xticklabel=\empty,      
xlabel=(2),     
        ]
        \addlegendimage{empty legend}
                \addplot[red, mark=+]  table{Annexes/resultats/BET/CUCEGRAPbjh1.dat};
                \addlegendentry{CuCe$_{2}$O$_{4}$/Graphite}                
        \nextgroupplot[legend pos=north east,
        legend style={draw=none},
        scaled ticks=false, %enlever le.10^-5 !!!!!!!!!!!!
        y tick label style={anchor=east},       
        ytick pos=left,
        scaled ticks=true,
        xmin=0,
        xmax=110,       
        xticklabel=\empty,  
xlabel=(3),     
        ]
                \addlegendimage{empty legend}
                \addplot[red, mark=+]  table{Annexes/resultats/BET/GRAPbjh1.dat};
                \addlegendentry{Graphite}               
        \nextgroupplot[legend pos=north east,
        legend style={draw=none},
        scaled ticks=false, %enlever le.10^-5 !!!!!!!!!!!!
        yticklabel pos=left,        
        ytick pos=left,
        scaled ticks=true,
        y tick label style={anchor=east},       
        xmin=0,
        xmax=100,       
        xticklabel=\empty,      
xlabel=(4),     
        ]
                \addlegendimage{empty legend}
                \addplot[red, mark=+]  table{Annexes/resultats/BET/CULAGRAPbjh1.dat};
                \addlegendentry{CuLa$_{2}$O$_{4}$/Graphite}               
        \nextgroupplot[legend pos=north east,
        legend style={draw=none},
        scaled ticks=false, %enlever le.10^-5 !!!!!!!!!!!!
        y tick label style={anchor=east},       
        ytick pos=left,
        scaled ticks=true,
        xmin=0,
        xmax=110,       
        xticklabel=\empty,
xlabel=(5),     
        ]
                \addlegendimage{empty legend}
                \addplot[red, mark=+]  table{Annexes/resultats/BET/GRAPbjh1.dat};
                \addlegendentry{Graphite}            
        \nextgroupplot[legend pos=north east,
        legend style={draw=none},
        scaled ticks=false, %enlever le.10^-5 !!!!!!!!!!!!
        yticklabel pos=left,
        ytick pos=left,
        scaled ticks=true,
        y tick label style={anchor=east},
        xmin=0,
        xmax=130,
        xticklabel=\empty,
xlabel=(6),     
        ]
        \addlegendimage{empty legend}
        \addplot[red, mark=+]  table{Annexes/resultats/BET/CUSMGRAPbjh1.dat};
        \addlegendentry{CuSm$_{2}$O$_{4}$/Graphite}
        \coordinate (bot) at (rel axis cs:0,0);% coordinate at bottom of the last plot
        \end{groupplot}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   \begin{groupplot}[group style={group size= 2 by 3,horizontal sep = 1.5cm,vertical sep =1.5cm},height=6.5cm,width=8cm
]
       \nextgroupplot[legend pos=north east,
        legend style={draw=none},
        scaled ticks=false, %enlever le.10^-5 !!!!!!!!!!!!*
        %ylabeltickpos= left,       
        %yticklabel pos=left,
        y tick label style={anchor=west},               
        yticklabel pos=right,
        ytick pos=right,
        scaled ticks=true,
        every y tick scale label/.append style={xshift=1cm},
        xmin=0,
        xmax=110,       
        ]
                \addlegendimage{empty legend};
                \addplot[green, mark=o] table{Annexes/resultats/BET/GRAPbjh2.dat};\label{plotsplot2}
                \addlegendentry{Graphite}[15 pt];               
                \coordinate (top) at (rel axis cs:0,1);% coordinate at top of the first plot            
        \nextgroupplot[legend pos=north east,
        legend style={draw=none},
        scaled ticks=false, %enlever le.10^-5 !!!!!!!!!!!!
        ytick pos=right,
        y tick label style={anchor=west},       
        xmin=0,
        xmax=140,       
        yticklabel pos=right,
        scaled ticks=true,
        every y tick scale label/.append style={xshift=1cm},
        ]
                legend pos=north east,
        legend style={draw=none},
        scaled ticks=false, %enlever le.10^-5 !!!!!!!!!!!!
        \addlegendimage{empty legend}
                \addplot[green, mark=o]   table{Annexes/resultats/BET/CUCEGRAPbjh2.dat};
                \addlegendentry{CuCe$_{2}$O$_{4}$/Graphite}                
        \nextgroupplot[legend pos=north east,
        legend style={draw=none},
        scaled ticks=false, %enlever le.10^-5 !!!!!!!!!!!!
        y tick label style={anchor=west},       
        xmin=0,
        xmax=110,       
        yticklabel pos=right,       
        ytick pos=right,
        scaled ticks=true,
        every y tick scale label/.append style={xshift=1cm},
        ]
                \addlegendimage{empty legend}
                \addplot[green, mark=o]   table{Annexes/resultats/BET/GRAPbjh2.dat};
                \addlegendentry{Graphite}               
        \nextgroupplot[legend pos=north east,
        legend style={draw=none},
        scaled ticks=false, %enlever le.10^-5 !!!!!!!!!!!!
        yticklabel pos=right,       
        ytick pos=right,
        scaled ticks=true,
        y tick label style={anchor=west},       
        xmin=0,
        xmax=100,       
        every y tick scale label/.append style={xshift=1cm},
        ]
                \addlegendimage{empty legend}
                \addplot[green, mark=o]   table{Annexes/resultats/BET/CULAGRAPbjh2.dat};
                \addlegendentry{CuLa$_{2}$O$_{4}$/Graphite}               
        \nextgroupplot[xlabel={Pression Relative p/p$°$}, legend pos=north east,
        legend style={draw=none},
        scaled ticks=false, %enlever le.10^-5 !!!!!!!!!!!!
        y tick label style={anchor=west},       
        xmin=0,
        xmax=110,
        yticklabel pos=right,
        ytick pos=right,    
        scaled ticks=true,  
every y tick scale label/.append style={xshift=1cm},        
        ]
                \addlegendimage{empty legend}
                \addplot[green, mark=o]   table{Annexes/resultats/BET/GRAPbjh2.dat};
                \addlegendentry{Graphite}            
        \nextgroupplot[xlabel={Pression Relative p/p$°$},
        legend pos=north east,
        legend style={draw=none},
        scaled ticks=false, %enlever le.10^-5 !!!!!!!!!!!!
        yticklabel pos=right,
        ytick pos=right,
        scaled ticks=true,
        y tick label style={anchor=west},
        xmin=0,
        xmax=130,
        every y tick scale label/.append style={xshift=1cm},
        ]
        \addlegendimage{empty legend}
                \addplot[green, mark=o]   table{Annexes/resultats/BET/CUSMGRAPbjh2.dat};
        \addlegendentry{CuSm$_{2}$O$_{4}$/Graphite}
                \coordinate (bot) at (rel axis cs:0,0);% coordinate at bottom of the last plot
    \end{groupplot}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \path (top-|current bounding box.west)-- node[anchor=south,rotate=90] {Quantité Adsorbée ($cm^{3}/g$ STP)} (bot-|current bounding box.west);
% legend
\path (top|-current bounding box.north)--
      coordinate(legendpos)
      (bot|-current bounding box.north);
\end{tikzpicture}
%\ref{named}
%\restoregeometry  
%***********************************************************
\chapter{Isothermes}
\pagebreak
\center{\huge{\hspace{2 cm}Isothermes}}\\
~\\
\begin{tikzpicture}
    \begin{groupplot}[group style={group size= 2 by 3},height=6.5cm,width=8cm]
       \nextgroupplot[legend pos=north west,
        legend style={draw=none},
        scaled ticks=false, %enlever le.10^-5 !!!!!!!!!!!!*
xlabel=(a),     
        ]
                \addlegendimage{empty legend};
                \addplot[red, mark=+] table{Annexes/resultats/BET/GRAP1.dat};\label{plotsplot1}
                \addplot[magenta, mark=o] table{Annexes/resultats/BET/GRAP2.dat};\label{plotsplot2}
                \addlegendentry{Graphite}[15 pt];               
                        \coordinate (top) at (rel axis cs:0,1);% coordinate at top of the first plot            
        \nextgroupplot[legend pos=north west,
        legend style={draw=none},
        scaled ticks=false, %enlever le.10^-5 !!!!!!!!!!!!
xlabel=(b),     
        ]
                legend pos=north west,
        legend style={draw=none},
        scaled ticks=false, %enlever le.10^-5 !!!!!!!!!!!!
        \addlegendimage{empty legend}
                \addplot[red, mark=+]  table{Annexes/resultats/BET/CUCEGRAP1.dat};
                \addplot[magenta, mark=o]   table{Annexes/resultats/BET/CUCEGRAP2.dat};
                \addlegendentry{CuCe$_{2}$O$_{4}$/Graphite}                
         \nextgroupplot[legend pos=north west,
        legend style={draw=none},
        scaled ticks=false, %enlever le.10^-5 !!!!!!!!!!!!
xlabel=(c),     
        ]
                \addlegendimage{empty legend}
                \addplot[red, mark=+]  table{Annexes/resultats/BET/GRAP1.dat};
                \addplot[magenta, mark=o]   table{Annexes/resultats/BET/GRAP2.dat};
                \addlegendentry{Graphite}               
              \nextgroupplot[legend pos=north west,
        legend style={draw=none},
        scaled ticks=false, %enlever le.10^-5 !!!!!!!!!!!!
xlabel=(d),     
        ]
                \addlegendimage{empty legend}
                \addplot[red, mark=+]  table{Annexes/resultats/BET/CULAGRAP1.dat};
                \addplot[magenta, mark=o]   table{Annexes/resultats/BET/CULAGRAP2.dat};
                \addlegendentry{CuLa$_{2}$O$_{4}$/Graphite}               
                      \nextgroupplot[xlabel={Pression Relative p/p$°$}, legend pos=north west,
        legend style={draw=none},
        scaled ticks=false, %enlever le.10^-5 !!!!!!!!!!!!
xlabel=(e),     
        ]
                \addlegendimage{empty legend}
                \addplot[red, mark=+]  table{Annexes/resultats/BET/GRAP1.dat};
                \addplot[magenta, mark=o]   table{Annexes/resultats/BET/GRAP2.dat};
                \addlegendentry{Graphite}            
                       \nextgroupplot[xlabel={Pression Relative p/p$°$},
        legend pos=north west,
        legend style={draw=none},
        scaled ticks=false, %enlever le.10^-5 !!!!!!!!!!!!
xlabel=(f),
]
        \addlegendimage{empty legend}
                \addplot[red, mark=+]  table{Annexes/resultats/BET/CUSMGRAP1.dat};
                \addplot[magenta, mark=o]   table{Annexes/resultats/BET/CUSMGRAP2.dat};
                %\addplot[green] table{Annexes/resultats/BET/GRAP1.dat};
        \addlegendentry{CuSm$_{2}$O$_{4}$/Graphite}
                \coordinate (bot) at (rel axis cs:0,0);% coordinate at bottom of the last plot
    \end{groupplot}
    \path (top-|current bounding box.west)-- node[anchor=south,rotate=90] {Quantité Adsorbée ($cm^{3}/g$ STP)} (bot-|current bounding box.west);
% legend
\path (top|-current bounding box.north)--
      coordinate(legendpos)
      (bot|-current bounding box.north);
\end{tikzpicture}
%\ref{named}
\end{document}
Hamza.w
  • 603
  • We cannot process you MWE because we do not have you .dat files. Unfortunately I do not know of a solution to your specific question. One possible mitigation might be a manual numbering via title and/or nodes inside a plot. Then you could also write about them in the main part of the caption (\caption[Short caption for LoF]{Main part}). – henry May 09 '15 at 11:02
  • you might be interested in package chemformula. – Johannes_B May 09 '15 at 11:18
  • What about Chemformula @Johannes_B ? – Hamza.w May 09 '15 at 12:47
  • It eases typesetting of chemical formula. It is automatically loaded by chemmacros, so i could use its power in my answer to your last question \ce{H2O} or \ce{CuCe2O4} – Johannes_B May 09 '15 at 12:53
  • @Johannes_B yes it is much eacier :) thanks – Hamza.w May 12 '15 at 17:39

1 Answers1

4

You can load subcaption and caption packages and use \captionof inside a node like

\node[text width=6cm,align=center,anchor=north] at ([yshift=-5mm]my plots c1r1.south) {\captionof{subfigure}{Pressure relative (P/P)\label{subplot:one}}};

The node option textwidthis needed for\captionof` to work inside the node.

\documentclass[french,12pt,oneside,openright]{memoir}

\usepackage{pgfplots}
\usepackage{caption,subcaption}  %for tables andfigures
\usepgfplotslibrary{groupplots}
\usetikzlibrary{matrix,positioning}
\begin{document}
\chapter{Some}
\section{some}
\clearpage
\begin{figure}[!h]
\renewcommand\thesubfigure{(\alph{subfigure})}
\centering
\caption{my plots}\label{fig:plots}
\begin{tikzpicture}
    \begin{groupplot}[group style={group name=my plots,group size= 2 by 3,horizontal sep =1.5cm,vertical sep =2cm},width=6cm]
       \nextgroupplot[legend pos=north east,
        legend style={draw=none},
        y tick label style={anchor=east},
        xticklabel=\empty,
        ytick pos=left,
        scaled ticks=true,
        xmin=0,
        xmax=130,
         xtick = {20,40,...,120},
        xticklabels={20,40,...,120},
         ]
                \addlegendimage{empty legend};
                \addplot[red, mark=+] {rnd};
                \addlegendentry{Graphite}[15 pt];
        \nextgroupplot[legend pos=north east,
        legend style={draw=none},
        scaled ticks=false,
        yticklabel pos=left,
        ytick pos=left,
        scaled ticks=true,
        y tick label style={anchor=east},
        xmin=0,
        xmax=130,
         xtick = {20,40,...,120},
        xticklabels={20,40,...,120},
        ]
        \addlegendimage{empty legend}
                \addplot[red, mark=+]  {rnd};
                \addlegendentry{CuCe$_{2}$O$_{4}$/Graphite}
        \nextgroupplot[legend pos=north east,
        legend style={draw=none},
        scaled ticks=false,
        y tick label style={anchor=east},
        ytick pos=left,
        scaled ticks=true,
        xmin=0,
        xmax=110,
         xtick = {20,40,...,120},
        xticklabels={20,40,...,120},
        ]
                \addlegendimage{empty legend}
                \addplot[red, mark=+]  {rnd};
                \addlegendentry{Graphite}
        \nextgroupplot[legend pos=north east,
        legend style={draw=none},
        scaled ticks=false,
        yticklabel pos=left,
        ytick pos=left,
        scaled ticks=true,
        y tick label style={anchor=east},
        xmin=0,
        xmax=100,
         xtick = {20,40,...,120},
        xticklabels={20,40,...,120},
        ]
                \addlegendimage{empty legend}
                \addplot[red, mark=+]  {rnd};
                \addlegendentry{CuLa$_{2}$O$_{4}$/Graphite}
        \nextgroupplot[legend pos=north east,
        legend style={draw=none},
        scaled ticks=false,
        y tick label style={anchor=east},
        ytick pos=left,
        scaled ticks=true,
        xmin=0,
        xmax=110,
         xtick = {20,40,...,120},
        xticklabels={20,40,...,120},
        ]
                \addlegendimage{empty legend}
                \addplot[red, mark=+]  {rnd};
                \addlegendentry{Graphite}
        \nextgroupplot[legend pos=north east,
        legend style={draw=none},
        scaled ticks=false,
        yticklabel pos=left,
        ytick pos=left,
        scaled ticks=true,
        y tick label style={anchor=east},
        xmin=0,
        xmax=130,
        xtick = {20,40,...,120},
        xticklabels={20,40,...,120},
        ]
        \addlegendimage{empty legend}
        \addplot[red, mark=+] {rnd};
        \addlegendentry{CuSm$_{2}$O$_{4}$/Graphite}
        \end{groupplot}
        \node[text width=6cm,align=center,anchor=north] at ([yshift=-5mm]my plots c1r1.south) {\captionof{subfigure}{Pressure relative (P/P)\label{subplot:one}}};
\node[text width=6cm,align=center,anchor=north] at ([yshift=-5mm]my plots c2r1.south) {\captionof{subfigure}{Pressure relative (P/P)\label{subplot:two}}};
\node[text width=6cm,align=center,anchor=north] at ([yshift=-5mm]my plots c1r2.south) {\captionof{subfigure}{Pressure relative (P/P)\label{subplot:three}}};
\node[text width=6cm,align=center,anchor=north] at ([yshift=-5mm]my plots c2r2.south) {\captionof{subfigure}{Pressure relative (P/P)\label{subplot:four}}};
\node[text width=6cm,align=center,anchor=north] at ([yshift=-5mm]my plots c1r3.south) {\captionof{subfigure}{Pressure relative (P/P)\label{subplot:five}}};
\node[text width=6cm,align=center,anchor=north] at ([yshift=-5mm]my plots c2r3.south) {\captionof{subfigure}{Pressure relative (P/P)\label{subplot:six}}};
\end{tikzpicture}
\end{figure}
\ref{subplot:one}
\end{document}

enter image description here

Tweaking the format of sub caption labels and reference format i further is left as an exercise.

  • it seems it worked for you, i mean i don't want that the xticklabesl and the xlabel/or caption interact between each other, i want to keep the xticklabels, thanks. – Hamza.w May 09 '15 at 12:49
  • @Hamza.w I don't understand. I assume that I have answered your question isn't it? :-) –  May 09 '15 at 12:55
  • hello @Harish Kumar sorry for the late reply, now i am turning to this part of work, and i am sorry to tell you , it didn't work, the subplot labels are intereacting( now i have numbers and alphabets between brackets) when using your code) and i want to keep the xticklabel not to omit them – Hamza.w May 12 '15 at 17:35
  • @Hamza.w Remove xticklabel=\empty and adjust the vertical sep suitably. –  May 12 '15 at 23:00
  • how can i input the vertical sep i mean i should put it where? – Hamza.w May 14 '15 at 17:40
  • @Hamza.w It is there already in the options of `\begin{groupplot} in the above answer. Just adjust the value. –  May 14 '15 at 23:32
  • but it doesn't shift move the values it only spread the plots, i want to shift the text between brackets in the first image, and after have the "pression relative P/P°" moved also lowered. thanks – Hamza.w May 15 '15 at 13:52
  • @Hamza.w Adjust the text width and use some yshift as in \node[text width=6cm,align=center,anchor=north] at ([yshift=-5mm]my plots c1r1.south) {\captionof{subfigure}{Pressure relative (P/P)\label{subplot:one}}}; –  May 15 '15 at 14:05
  • Thanks for your answer :) , my last question: can i keep the xlabel with the node if yes, can you please tell me how to shift just the xlabel ( the node is done :) ) – Hamza.w May 15 '15 at 14:24
  • @Hamza.w Just put the label like {xlabel \\ Pressure relative..}; –  May 15 '15 at 14:27
  • it didn't work the \ – Hamza.w May 15 '15 at 14:57