I am trying to have a boxplot from data , with two lines and frequency in the second line. example:
I don't know how to do it, with a "foreach " or special command for boxplot ( pgfplots )
\documentclass[png,tikz,border=30pt]{standalone}
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}% version
\usetikzlibrary{pgfplots.statistics}
\begin{document}
\begin{tabular}{|c|c|c|c|c|c|c|}\hline centre de classe & 0.5 & 1.5 & 2.5 & 3.5 & 4.5 & 5.5
\\\hline effectif & 2 &3 &4 &5 &2
& 1\\\hline
\end{tabular}
% % % % % % %
% % % % % % % % i need to do this % % % % % % %
\begin{tikzpicture}
\begin{axis}[y=1.5cm, ymax=2]
\addplot+[boxplot]
table[row sep=\\,y index=0] {
data\\
0.5 \\ 0.5 \\ 1.5 \\ 1.5 \\1.5 \\ 2.5 \\ 2.5 \\2.5 \\2.5 \\ 3.5\\ 3.5\\3.5\\3.5\\3.5\\ 4.5 \\ 4.5 \\5.5 \\
}
[above]
node at
(boxplot box cs: \boxplotvalue{lower whisker},1)
{\pgfmathprintnumber{\boxplotvalue{lower whisker}}}
node at
(boxplot box cs: \boxplotvalue{lower quartile},1)
{\pgfmathprintnumber{\boxplotvalue{lower quartile}}}
node[left] at
(boxplot box cs: \boxplotvalue{median},0.5)
{\pgfmathprintnumber{\boxplotvalue{median}}}
node at
(boxplot box cs: \boxplotvalue{upper quartile},1)
{\pgfmathprintnumber{\boxplotvalue{upper quartile}}}
node at
(boxplot box cs: \boxplotvalue{upper whisker},1)
{\pgfmathprintnumber{\boxplotvalue{upper whisker}}}
;
\end{axis}
\end{tikzpicture}
\end{document}
I tried with for each :
\usepackage[francais]{babel}% pour avoir \addto
\usepackage{amsmath}
\newcommand*\eaddto[2]{% version développée de \addto
\edef\tmp{#2}%
\expandafter\addto
\expandafter#1%
\expandafter{\tmp}%
}
\newcommand{\essai}{}
\foreach \x in {1,...,2}
{\eaddto\essai{ 0.5 \symbol{92} \symbol{92} }}
\foreach \x in {1,...,3}
{\eaddto\essai{ 1.5 \symbol{92} \symbol{92} }}
\foreach \x in {1,...,4}
{\eaddto\essai{ 2.5 \symbol{92} \symbol{92} }}
\foreach \x in {1,...,5}
{\eaddto\essai{ 3.5 \symbol{92} \symbol{92} }}
\begin{align*}
\essai
\end{align*}
\foreach \x in {1,...,2}
{\eaddto\essai{ 4.5 \symbol{92} \symbol{92} }}
\begin{align*}
\essai
\end{align*}
so, \essai
gives " 0.5 \ 0.5 \ 1.5 \1.5 \1.5 ....." but I don't know how to use it in boxplot context