1

I cannot figure out which code am I typing wrong, I'd like to insert multiple graphs in one figure, each graph captioned a) b) c) etc..

Here is my document:

\documentclass{article}
    \usepackage{pgfplots,tikz}

    \usepackage{subcaption}
    \begin{document}
  \begin{figure}
    \begin{subfigure}{\textwidth}
          \begin{tikzpicture}
        \begin{axis}[title={Scientifico - totale L e LS}, 
xmin=2004, xmax=2012,
ymin=0.10, ymax=0.85, 
xlabel={Anno di laurea}, 
xlabel near ticks, 
ylabel={media occupati}, 
xtick={2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012},
ytick={0.1, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90, 1},
xticklabels={2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012},
xticklabel style={rotate=-60, align=right},
legend cell align=left,
legend pos=outer north east,
ymajorgrids=true,
grid style=dashed,
]
\addplot 
coordinates {(2004, 0.46) (2005, 0.50) (2006, 0.62) (2007, 0.58) (2008, 0.43) (2009, 0.44) (2010, 0.52) (2011, 0.39) (2012, 0.38)};
\addplot 
coordinates {(2004, 0.63) (2005, 0.72) (2006, 0.73) (2007, 0.74) (2008,0.74) (2009, 0.59) (2010,0.71)};
\addplot 
coordinates {(2004, 0.71) (2005, 0.75) (2006, 0.84) (2007, 0.87) (2008, 0.80)};     
\legend{1 anno, 3 anni, 5 anni}  
        \end{axis}
        \end{tikzpicture}
    \caption{scientifico}   
\end{subfigure}

\begin{subfigure}{\textwidth}
          \begin{tikzpicture}
        \begin{axis}[title={Economico-statistico}, 
xmin=2004, xmax=2012,
ymin=0.10, ymax=0.85, 
xlabel={Anno di laurea}, 
xlabel near ticks, 
ylabel={media occupati}, 
xtick={2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012},
ytick={0.1, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90, 1},
xticklabels={2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012},
xticklabel style={rotate=-60, align=right},
legend cell align=left,
legend pos=outer north east,
ymajorgrids=true,
grid style=dashed,
]
\addplot 
coordinates {(2004, 0.59) (2005, 0.55) (2006, 0.65) (2007, 0.41) (2008, 0.38) (2009, 0.40) (2010, 0.37) (2011, 0.36) (2012, 0.36)};
\addplot 
coordinates {(2004, 0.81) (2005, 0.77) (2006, 0.80) (2007, 0.79) (2008,0.84) (2009, 0.81) (2010,0.86)};
\addplot 
coordinates {(2004, 0.99) (2005, 0.91) (2006, 1) (2007, 0.91) (2008, 0.94)};        
\legend{1 anno, 3 anni, 5 anni}  
        \end{axis}
        \end{tikzpicture}
    \caption{economico-statistico}  
\end{subfigure}

\begin{subfigure}{\textwidth}
          \begin{tikzpicture}
    \begin{axis}[title={Giuridico}, 
xmin=2004, xmax=2012,
ymin=0.10, ymax=0.85, 
xlabel={Anno di laurea}, 
xlabel near ticks, 
ylabel={media occupati}, 
xtick={2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012},
ytick={0.1, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90, 1},
xticklabels={2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012},
xticklabel style={rotate=-60, align=right},
legend cell align=left,
legend pos=outer north east,
ymajorgrids=true,
grid style=dashed,
]
\addplot 
coordinates {(2004, 0.24) (2005, 0.19) (2006, 0.35) (2007, 0.20) (2008, 0.14) (2009, 0.24) (2010, 0.34) (2011, 0.32) (2012, 0.34)};
\addplot 
coordinates {(2004, 0.45) (2005, 0.72) (2006, 0.71) (2007, 0.44) (2008,0.50) (2009, 0.63) (2010,0.61)};
\addplot 
coordinates {(2004, 0.92) (2005, 0.96) (2006, 0.94) (2007, 0.83) (2008, 0.68)};     
\legend{1 anno, 3 anni, 5 anni}  
        \end{axis}
        \end{tikzpicture}
    \caption{giuridico} 
\end{subfigure}

\begin{subfigure}{\textwidth}
\begin{tikzpicture}
    \begin{axis}[title={Medico}, 
xmin=2004, xmax=2012,
ymin=0.10, ymax=0.85, 
xlabel={Anno di laurea}, 
xlabel near ticks, 
ylabel={media occupati}, 
xtick={2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012},
ytick={0.1, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90, 1},
xticklabels={2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012},
xticklabel style={rotate=-60, align=right},
legend cell align=left,
legend pos=outer north east,
ymajorgrids=true,
grid style=dashed,
]
\addplot 
coordinates {(2004, 0.26) (2005, 0.22) (2006, 0.31) (2007, 0.80) (2008, 0.82) (2009, 0.78) (2010, 0.74) (2011, 0.78) (2012, 0.71)};
\addplot 
coordinates {(2004, 0.35) (2005, 0.23) (2006, 0.31) (2007, 0.42) (2008,0.48) (2009, 0.48) (2010,0.39)};
\addplot 
coordinates {(2004, 0.59) (2005, 0.57) (2006, 0.38) (2007, 0.60) (2008, 0.49)};     
\legend{1 anno, 3 anni, 5 anni}  
        \end{axis}
        \end{tikzpicture}
    \caption{medico}    
\end{subfigure}

\begin{subfigure}{\textwidth}
\begin{tikzpicture}
    \begin{axis}[title={Ed.fisica}, 
xmin=2004, xmax=2012,
ymin=0.10, ymax=0.85, 
xlabel={Anno di laurea}, 
xlabel near ticks, 
ylabel={media occupati}, 
xtick={2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012},
ytick={0.1, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90, 1},
xticklabels={2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012},
xticklabel style={rotate=-60, align=right},
legend cell align=left,
legend pos=outer north east,
ymajorgrids=true,
grid style=dashed,
]
\addplot 
coordinates {(2004, 0.63) (2005, 0.40) (2006, 0.79) (2007, 0.69) (2008, 0.58) (2009, 0.57) (2010, 0.63) (2011, 0.66) (2012, 0.64)};
\addplot 
coordinates {(2004, ) (2005, ) (2006, ) (2007, 0.96) (2008,0.81) (2009, 0.95) (2010,0.86)};
\addplot 
coordinates {(2004, ) (2005, ) (2006, ) (2007, 0.96) (2008, 0.83)};     
\legend{1 anno, 3 anni, 5 anni}  
        \end{axis}
        \end{tikzpicture}
    \caption{ed.fisica} 
\end{subfigure}

\begin{subfigure}{\textwidth}
\begin{tikzpicture}
    \begin{axis}[title={Umanistico}, 
xmin=2004, xmax=2012,
ymin=0.10, ymax=0.85, 
xlabel={Anno di laurea}, 
xlabel near ticks, 
ylabel={media occupati}, 
xtick={2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012},
ytick={0.1, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90, 1},
xticklabels={2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012},
xticklabel style={rotate=-60, align=right},
legend cell align=left,
legend pos=outer north east,
ymajorgrids=true,
grid style=dashed,
]
\addplot 
coordinates {(2004, 0.78) (2005, 0.64) (2006, 0.79) (2007, 0.52) (2008, 0.48) (2009, 0.49) (2010, 0.49) (2011, 0.51) (2012, 0.50)};
\addplot 
coordinates {(2004, 0.92) (2005, 0.90) (2006, 0.83) (2007, 0.81) (2008,0.80) (2009, 0.85) (2010,0.81)};
\addplot 
coordinates {(2004, 0.91) (2005, 0.88) (2006, 0.89) (2007, 0.83) (2008, 0.88)};     
\legend{1 anno, 3 anni, 5 anni}  
        \end{axis}
        \end{tikzpicture}
    \caption{umanistico}    
\end{subfigure}

\end{figure}

\end{document}
Claudia
  • 11
  • Hi Claudia, welcome to the site! You have invalid coordinates in your last plot, (2004, ) (2005, ) (2006, ). Fix those and the errors go away =) – Jake Mar 19 '15 at 17:15
  • In one of your plots there are missing y components in coordinates: coordinates {(2004, ) (2005, ) (2006, ). Apart from this, there is not enough space in one page for so many figures. You can plot all of them but distribute between different figures. – Ignasi Mar 19 '15 at 17:22
  • Thanks a lot!If I scale all 6 figures to 0.5 they can fit in A4 page...but how can I organize them in the same page? For instance 3 graphs on the left and 3 graphs on the right of the page (that is into two columns)? – Claudia Mar 19 '15 at 18:24
  • If you use subfigures with widths .3\textwidth or so, you should get 3 across. Or you could use a tabular and \captionof{subfigure}. Assuming they will fit, of course. I like to throw in the occasional \noindent\rule{\textwidth}{1pt} just to check. – John Kormylo Mar 20 '15 at 03:36

0 Answers0