% proflycee-tools-stats.tex % Copyright 2023-2024 Cédric Pierquet % Released under the LaTeX Project Public License v1.3c or later, see http://www.latex-project.org/lppl.txt %3.01a Courbe ECC %2.6.8 Grille histogrammes non réguliers %2.6.7 Histogrammes %%------RegressionLinéaire %calcul des paramètres \defKV[coeffreglin]{% NomCoeffa=\def\RegLinCoeffa{#1},% NomCoeffb=\def\RegLinCoeffb{#1},% NomCoeffr=\def\RegLinCoeffr{#1},% NomCoeffrd=\def\RegLinCoeffrd{#1},% NomXmin=\def\RegLinCoeffXmin{#1},% NomXmax=\def\RegLinCoeffXmax{#1} } \setKVdefault[coeffreglin]{% NomCoeffa=COEFFa,% NomCoeffb=COEFFb,% NomCoeffr=COEFFr,% NomCoeffrd=COEFFrd,% NomXmin=LXmin,% NomXmax=LXmax } \newcommand\CalculsRegLin[3][]{% \useKVdefault[coeffreglin]% \setKV[coeffreglin]{#1}% on paramètres les nouvelles clés et on les simplifie %xmin et xmax \expandafter\def\csname\RegLinCoeffXmin\endcsname{\fpeval{min(#2)}} \expandafter\def\csname\RegLinCoeffXmax\endcsname{\fpeval{max(#2)}} %listes des données \def\xliste{#2} \def\yliste{#3} \readlist*\LX{\xliste} \readlist*\LY{\yliste} %taille des listes \def\LNB{\inteval{\LXlen}} %somme des LX et des LY OK \xdef\LXSomme{0} \xdef\LYSomme{0} \foreach \i in {1,2,...,\LNB}{ \xdef\LXSomme{\fpeval{\LXSomme+\LX[\i]}} } \foreach \i in {1,2,...,\LNB}{ \xdef\LYSomme{\fpeval{\LYSomme+\LY[\i]}} } %moyenne des LX et des LY OK \xdef\LXmoy{\fpeval{\LXSomme/\LNB}} \xdef\LYmoy{\fpeval{\LYSomme/\LNB}} %variance des LX et des LY OK \xdef\LXvar{0} \foreach \i in {1,2,...,\LNB}{ \xdef\LXvar{\fpeval{\LXvar+(\LX[\i]-\LXmoy)*(\LX[\i]-\LXmoy)}} } \xdef\LXvar{\fpeval{\LXvar/\LNB}} \xdef\LYvar{0} \foreach \i in {1,2,...,\LNB}{ \xdef\LYvar{\fpeval{\LYvar+(\LY[\i]-\LYmoy)*(\LY[\i]-\LYmoy)}} } \xdef\LYvar{\fpeval{\LYvar/\LNB}} %covariance des XY OK \xdef\LXYvar{0} \foreach \i in {1,2,...,\LNB}{ \xdef\LXYvar{\fpeval{\LXYvar+(\LX[\i]-\LXmoy)*(\LY[\i]-\LYmoy)}} } \xdef\LXYvar{\fpeval{\LXYvar/\LNB}} %COEFFS OK \expandafter\def\csname\RegLinCoeffa\endcsname{\fpeval{\LXYvar/\LXvar}} \expandafter\def\csname\RegLinCoeffb\endcsname{\fpeval{\LYmoy-\csname\RegLinCoeffa\endcsname*\LXmoy}} \expandafter\def\csname\RegLinCoeffr\endcsname{\fpeval{\LXYvar/sqrt(\LXvar*\LYvar)}} \expandafter\def\csname\RegLinCoeffrd\endcsname{\fpeval{\csname\RegLinCoeffr\endcsname*\csname\RegLinCoeffr\endcsname}} } %pour un nuage en TiKz \defKV[nuagereglin]{% Couleur=\def\RegLinNuageCouleur{#1},% Taille=\def\RegLinNuageTaille{#1}, Ox=\def\RegLinNuageOx{#1},% Oy=\def\RegLinNuageOy{#1},% } \setKVdefault[nuagereglin]{% Couleur=teal,% Taille=2pt,% Ox=0,% Oy=0 } \newcommand\PointsRegLin[3][]{% \useKVdefault[nuagereglin] \setKV[nuagereglin]{#1}% on paramètres les nouvelles clés et on les simplifie \def\xliste{#2} \def\yliste{#3} \readlist*\LX{\xliste} \readlist*\LY{\yliste} %taille des listes \def\LNB{\inteval{\LXlen}} \foreach \i in {1,2,...,\LNB} {\filldraw[\RegLinNuageCouleur] ({\LX[\i]-\RegLinNuageOx},{\LY[\i]-\RegLinNuageOy}) circle[radius=\RegLinNuageTaille] ;} } \NewDocumentEnvironment{StatsTikz}{ O{} } {% \begin{tikzpicture}[#1] }% {% \end{tikzpicture}% } %%------BOITES MOUSTACHES \defKV[boiteamoustaches]{% Couleur=\def\BaMCouleur{#1},% Elevation=\def\BaMElevation{#1},% Hauteur=\def\BaMHauteur{#1},% Moyenne=\def\BaMMoyenne{#1},% Epaisseur=\def\BaMEpaisseur{#1},% Remplir=\def\BaMRemplissage{#1} } \setKVdefault[boiteamoustaches]{% Couleur=black,% Elevation=1,% Hauteur=1,% AffMoyenne=false,% Epaisseur=thick,% Pointilles=false,% Valeurs=false,% Remplir=white } \defKV[boiteamoustachesaxe]{% Min=\def\BaMAxeMin{#1},% Max=\def\BaMAxeMax{#1},% Elargir=\def\BaMAxeElarg{#1},% Epaisseur=\def\BaMAxeEpaisseur{#1},% Valeurs=\def\BaMAxeValeurs{#1} } \setKVdefault[boiteamoustachesaxe]{% Elargir=0.05,% Epaisseur=thick,% AffValeurs=false } \newcommand\BoiteMoustachesAxe[1][]{ \useKVdefault[boiteamoustachesaxe] \setKV[boiteamoustachesaxe]{#1} \def\BaMaxelargeur{\fpeval{\BaMAxeMax-\BaMAxeMin}} \def\BaMaxexmin{\fpeval{\BaMAxeMin-\BaMAxeElarg*\BaMaxelargeur}} \def\BaMaxexmax{\fpeval{\BaMAxeMax+\BaMAxeElarg*\BaMaxelargeur}} \draw[\BaMAxeEpaisseur,->,>=latex] (\BaMaxexmin,0) -- (\BaMaxexmax,0) ; \ifboolKV[boiteamoustachesaxe]{AffValeurs} {\foreach \x in \BaMAxeValeurs \draw[\BaMAxeEpaisseur] (\x,3pt)--(\x,-3pt) node[below=3pt] {\num{\x}} ;} {} } \newcommand\BoiteMoustaches[2][]{ \useKVdefault[boiteamoustaches] \setKV[boiteamoustaches]{#1} \setsepchar[.]{/}% \readlist*\BaMListeparams{#2}% \itemtomacro\BaMListeparams[1]\BaMmin% \itemtomacro\BaMListeparams[2]\BaMqu% \itemtomacro\BaMListeparams[3]\BaMmed% \itemtomacro\BaMListeparams[4]\BaMqt% \itemtomacro\BaMListeparams[5]\BaMmax% \draw[draw,\BaMEpaisseur,\BaMCouleur,fill=\BaMRemplissage] ({\BaMqu},{\BaMElevation-0.5*\BaMHauteur}) rectangle ({\BaMqt},{\BaMElevation+0.5*\BaMHauteur}) ; \draw[\BaMEpaisseur,\BaMCouleur] (\BaMmin,{\BaMElevation-0.5*\BaMHauteur})--(\BaMmin,{\BaMElevation+0.5*\BaMHauteur}) (\BaMmax,{\BaMElevation-0.5*\BaMHauteur})--(\BaMmax,{\BaMElevation+0.5*\BaMHauteur}) (\BaMmed,{\BaMElevation-0.5*\BaMHauteur})--(\BaMmed,{\BaMElevation+0.5*\BaMHauteur}); \draw[\BaMEpaisseur,\BaMCouleur] ({\BaMmin},{\BaMElevation})--({\BaMqu},{\BaMElevation}) ({\BaMqt},{\BaMElevation})--({\BaMmax},{\BaMElevation}) ; \ifboolKV[boiteamoustaches]{AffMoyenne} {\filldraw[\BaMCouleur] ({\BaMMoyenne},{\BaMElevation}) circle[radius=2.5pt] ;} {} \ifboolKV[boiteamoustaches]{Pointilles} { \draw[\BaMEpaisseur,densely dashed] (\BaMmin,{\BaMElevation-0.5*\BaMHauteur}) -- (\BaMmin,0) ; \draw[\BaMEpaisseur,densely dashed] (\BaMqu,{\BaMElevation-0.5*\BaMHauteur}) -- (\BaMqu,0) ; \draw[\BaMEpaisseur,densely dashed] (\BaMmed,{\BaMElevation-0.5*\BaMHauteur}) -- (\BaMmed,0) ; \draw[\BaMEpaisseur,densely dashed] (\BaMqt,{\BaMElevation-0.5*\BaMHauteur}) -- (\BaMqt,0) ; \draw[\BaMEpaisseur,densely dashed] (\BaMmax,{\BaMElevation-0.5*\BaMHauteur}) -- (\BaMmax,0) ; } {} \ifboolKV[boiteamoustaches]{Valeurs} { \filldraw (\BaMmin,0) circle[radius=2pt] node[below=4pt] {\num{\BaMmin}} ; \filldraw (\BaMqu,0) circle[radius=2pt] node[below=4pt] {\num{\BaMqu}} ; \filldraw (\BaMmed,0) circle[radius=2pt] node[below=4pt] {\num{\BaMmed}} ; \filldraw (\BaMqt,0) circle[radius=2pt] node[below=4pt] {\num{\BaMqt}} ; \filldraw (\BaMmax,0) circle[radius=2pt] node[below=4pt] {\num{\BaMmax}} ; } {} } %%------HISTOGRAMME \defKV[histostats]{% ListeCouleurs=\def\HistoCouleurs{#1},% Largeur=\def\HistoLargeur{#1},% Hauteur=\def\HistoHauteur{#1},% GradX=\def\HistoGradX{#1},% GradY=\def\HistoGradY{#1},% PosEffectifs=\def\HistoPosEff{#1},% LabelX=\def\HistoLabelx{#1},% LabelY=\def\HistoLabely{#1},% ElargirX=\def\HistoElargirx{#1},% ElargirY=\def\HistoElargiry{#1},% PoliceAxes=\def\HistoFonte{#1},% PoliceEffectifs=\def\HistoFonteEff{#1},% Opacite=\def\HistoOpac{#1},% DebutOx=\def\HistoDebX{#1},% FinOx=\def\HistoFinX{#1},% EpaisseurTraits=\def\HistoEptraits{#1},% Grille=\def\HistoGrille{#1},% ExtraGrilleY=\def\HistoExtraGridY{#1},% PosLegende=\def\HistoPosLeg{#1} } \setKVdefault[histostats]{% ListeCouleurs=orange,% Largeur=10,% Hauteur=5,% GradX={},% GradY={},% AffEffectifs=true,% PosEffectifs=milieu,% ElargirX=5mm,% ElargirY=5mm,% LabelX={},% LabelY={},% PoliceAxes=\normalsize\normalfont,% PoliceEffectifs=\normalsize\normalfont,% AffBornes=false,% Remplir=true,% Opacite=0.5,% GrilleV=true,% DebutOx={},% FinOx={},% EpaisseurTraits=semithick,% Grille={},% ExtraGrilleY=0,% PosLegende={} } \NewDocumentCommand\Histogramme{ s O{} m }{% \useKVdefault[histostats]% \setKV[histostats]{#2}% \setsepchar[.]{ ./}% \readlist*\LISTDONNEES{#3}% \IfEq{\HistoDebX}{}%on stocke le début de l'axe Ox si besoin {\itemtomacro\LISTDONNEES[1,1]{\HistoDebX}}{}% \IfEq{\HistoFinX}{}%on stocke la fin de l'axe Ox si besoin {\itemtomacro\LISTDONNEES[-1,2]{\HistoFinX}}{}% \setsepchar{,}% \readlist*\LISTCOUL{\HistoCouleurs}% %distinction suivant largeur classes \IfBooleanTF{#1}%étoilé := classe d'amplitudes différentes {% \xdef\ListeHauteurs{\xintfloateval{(\LISTDONNEES[1,3])/(\LISTDONNEES[1,2]-\LISTDONNEES[1,1])}} \foreach \i in {2,...,\LISTDONNEESlen} {% \xdef\ListeHauteurs{\ListeHauteurs,\xintfloateval{(\LISTDONNEES[\i,3])/(\LISTDONNEES[\i,2]-\LISTDONNEES[\i,1])}}% }% \IfEq{\HistoGrille}{}%on lit les infos de la grille PasX/UniteAire {}% {% \StrCut{\HistoGrille}{/}{\HistoPasX}{\HistoUnAire}% \def\HistoPasY{\xintfloateval{\HistoUnAire/\HistoPasX}}% }% \xdef\maxhauteurs{\xintfloateval{round(max(\ListeHauteurs),3)}}% \IfEq{\HistoGrille}{}% {% \xdef\HistoUniteY{\xintfloateval{round(\HistoHauteur/max(\ListeHauteurs),3)}}% }% {% \xdef\maxhauteurgrille{\xinteval{(floor((\maxhauteurs)/(\HistoPasY))+1+\HistoExtraGridY)*\HistoPasY}}% \xdef\HistoUniteY{\xintfloateval{round((\HistoHauteur)/(\maxhauteurgrille),3)}}% }% \xdef\HistoUniteX{\xintfloateval{round(\HistoLargeur/(\HistoFinX-\HistoDebX),3)}}% %fenêtre graphique \begin{tikzpicture}[x=\HistoUniteX cm,y=\HistoUniteY cm] %Essai de grille \IfEq{\HistoGrille}{}% {}% {% \draw[line width=0.4pt,lightgray,xstep=\HistoPasX,ystep=\HistoPasY] ({\HistoDebX},0) grid ({\HistoFinX},{\xinteval{floor((\maxhauteurs)/(\HistoPasY))+1+\HistoExtraGridY}*\HistoPasY}) ; \IfSubStr{\HistoPosLeg}{/}% {% \StrCut{\HistoPosLeg}{/}{\HistoPosLegX}{\HistoPosLegY}% \draw[\HistoEptraits,fill=lightgray,fill opacity=\HistoOpac] ({\HistoDebX+(\HistoPosLegX)*(\HistoPasX)},{(\HistoPasY)*(\HistoPosLegY)}) rectangle++ ({\HistoPasX},{\HistoPasY}) ; % \draw ({\HistoDebX+(\HistoPosLegX+1)*(\HistoPasX)},{(\HistoPasY)*(\HistoPosLegY+0.5)}) node[right,font=\HistoFonteEff] {\num{\HistoUnAire}} ;% }% {}% %\draw ({\HistoDebX},{0}) node[below left] {\xinteval{floor((\maxhauteurs)/(\HistoPasY))+1}} ; %\draw ({\HistoDebX},{\HistoPasY}) node[left] {\num{\HistoPasY}} ; %\draw ({\HistoDebX},{\maxhauteurs}) node[left] {\num{\maxhauteurs}} ; }% %rectangles \foreach \i in {1,...,\LISTDONNEESlen} {% \xintifboolexpr{\LISTCOULlen == 1}% {\def\couleurhisto{\HistoCouleurs}}% {\itemtomacro\LISTCOUL[\i]{\couleurhisto}}% \ifboolKV[histostats]{AffBornes}% {% \draw[\HistoEptraits] ({\LISTDONNEES[\i,1]},3pt)--++(0,-6pt) node[below,font=\HistoFonte] {\LISTDONNEES[\i,1]} ; \draw[\HistoEptraits] ({\LISTDONNEES[\i,2]},3pt)--++(0,-6pt) node[below,font=\HistoFonte] {\LISTDONNEES[\i,2]} ; }% {}% \ifboolKV[histostats]{Remplir}% {% \draw[\HistoEptraits,fill=\couleurhisto,fill opacity=\HistoOpac] ({\LISTDONNEES[\i,1]},0) rectangle ({\LISTDONNEES[\i,2]},{(\LISTDONNEES[\i,3])/(\LISTDONNEES[\i,2]-\LISTDONNEES[\i,1])}) ; }% {% \draw[\HistoEptraits] ({\LISTDONNEES[\i,1]},0) rectangle ({\LISTDONNEES[\i,2]},{(\LISTDONNEES[\i,3])/(\LISTDONNEES[\i,2]-\LISTDONNEES[\i,1])}) ; }% }% \foreach \x in \HistoGradX {% \draw[\HistoEptraits] (\x,3pt)--++(0,-6pt) node[below,font=\HistoFonte] {\num{\x}} ; }% \ifboolKV[histostats]{AffEffectifs} {% \IfStrEq{\HistoPosEff}{milieu}% {% \foreach \i in {1,...,\LISTDONNEESlen} \draw ({0.5*\LISTDONNEES[\i,1]+0.5*\LISTDONNEES[\i,2]},{0.5*(\LISTDONNEES[\i,3])/(\LISTDONNEES[\i,2]-\LISTDONNEES[\i,1])}) node[font=\HistoFonteEff] {\num{\LISTDONNEES[\i,3]}} ; }% {}% \IfStrEq{\HistoPosEff}{bas}% {% \foreach \i in {1,...,\LISTDONNEESlen} \draw ({0.5*\LISTDONNEES[\i,1]+0.5*\LISTDONNEES[\i,2]},{0}) node[above,font=\HistoFonteEff] {\num{\LISTDONNEES[\i,3]}} ; }% {}% \IfStrEq{\HistoPosEff}{haut}% {% \foreach \i in {1,...,\LISTDONNEESlen} \draw ({0.5*\LISTDONNEES[\i,1]+0.5*\LISTDONNEES[\i,2]},{(\LISTDONNEES[\i,3])/(\LISTDONNEES[\i,2]-\LISTDONNEES[\i,1])}) node[below,font=\HistoFonteEff] {\num{\LISTDONNEES[\i,3]}} ; }% {}% \IfStrEq{\HistoPosEff}{dessus}% {% \foreach \i in {1,...,\LISTDONNEESlen} \draw ({0.5*\LISTDONNEES[\i,1]+0.5*\LISTDONNEES[\i,2]},{(\LISTDONNEES[\i,3])/(\LISTDONNEES[\i,2]-\LISTDONNEES[\i,1])}) node[above,font=\HistoFonteEff] {\num{\LISTDONNEES[\i,3]}} ; }% {}% }% {}% \draw[\HistoEptraits,->,>=latex] ({\HistoDebX},0) -- ({\HistoFinX},0) --++ ({\HistoElargirx},0) node[right,font=\HistoFonte] {\HistoLabelx} ; \end{tikzpicture}% }% {% \xdef\ListeHauteurs{\LISTDONNEES[1,3]} \foreach \i in {2,...,\LISTDONNEESlen} {% \xdef\ListeHauteurs{\ListeHauteurs,\LISTDONNEES[\i,3]}% }% \xdef\maxhauteurs{\xinteval{round(max(\ListeHauteurs),3)}}% \xdef\HistoUniteY{\xinteval{round(\HistoHauteur/max(\ListeHauteurs),3)}}% \xdef\HistoUniteX{\xinteval{round(\HistoLargeur/(\HistoFinX-\HistoDebX),3)}}% %fenêtre graphique \begin{tikzpicture}[x=\HistoUniteX cm,y=\HistoUniteY cm] \ifboolKV[histostats]{GrilleV}% {% \foreach \y in \HistoGradY {% \draw[line width=0.4pt,lightgray] ({\HistoDebX},\y) -- ({\HistoFinX},\y) --++ ({\HistoElargirx},0) ; }% }% {}% \foreach \i in {1,...,\LISTDONNEESlen} {% \xintifboolexpr{\LISTCOULlen == 1}% {\def\couleurhisto{\HistoCouleurs}}% {\itemtomacro\LISTCOUL[\i]{\couleurhisto}}% \ifboolKV[histostats]{AffBornes}% {% \draw[\HistoEptraits] ({\LISTDONNEES[\i,1]},3pt)--++(0,-6pt) node[below,font=\HistoFonte] {\LISTDONNEES[\i,1]} ; \draw[\HistoEptraits] ({\LISTDONNEES[\i,2]},3pt)--++(0,-6pt) node[below,font=\HistoFonte] {\LISTDONNEES[\i,2]} ; }% {}% \ifboolKV[histostats]{Remplir}% {% \draw[\HistoEptraits,fill=\couleurhisto,fill opacity=\HistoOpac] ({\LISTDONNEES[\i,1]},0) rectangle ({\LISTDONNEES[\i,2]},{\LISTDONNEES[\i,3]}) ; }% {% \draw[\HistoEptraits] ({\LISTDONNEES[\i,1]},0) rectangle ({\LISTDONNEES[\i,2]},{\LISTDONNEES[\i,3]}) ; }% }% \foreach \x in \HistoGradX {% \draw[\HistoEptraits] (\x,3pt)--++(0,-6pt) node[below,font=\HistoFonte] {\num{\x}} ; }% \foreach \y in \HistoGradY {% \draw[\HistoEptraits] ($({\HistoDebX},\y)+(3pt,0)$) --++ (-6pt,0) node[left,font=\HistoFonte] {\num{\y}} ; }% \ifboolKV[histostats]{AffEffectifs} {% \IfStrEq{\HistoPosEff}{milieu}% {% \foreach \i in {1,...,\LISTDONNEESlen} \draw ({0.5*\LISTDONNEES[\i,1]+0.5*\LISTDONNEES[\i,2]},{0.5*\LISTDONNEES[\i,3]}) node[font=\HistoFonteEff] {\num{\LISTDONNEES[\i,3]}} ; }% {}% \IfStrEq{\HistoPosEff}{bas}% {% \foreach \i in {1,...,\LISTDONNEESlen} \draw ({0.5*\LISTDONNEES[\i,1]+0.5*\LISTDONNEES[\i,2]},{0}) node[above,font=\HistoFonteEff] {\num{\LISTDONNEES[\i,3]}} ; }% {}% \IfStrEq{\HistoPosEff}{haut}% {% \foreach \i in {1,...,\LISTDONNEESlen} \draw ({0.5*\LISTDONNEES[\i,1]+0.5*\LISTDONNEES[\i,2]},{\LISTDONNEES[\i,3]}) node[below,font=\HistoFonteEff] {\num{\LISTDONNEES[\i,3]}} ; }% {}% \IfStrEq{\HistoPosEff}{dessus}% {% \foreach \i in {1,...,\LISTDONNEESlen} \draw ({0.5*\LISTDONNEES[\i,1]+0.5*\LISTDONNEES[\i,2]},{\LISTDONNEES[\i,3]}) node[above,font=\HistoFonteEff] {\num{\LISTDONNEES[\i,3]}} ; }% {}% }% {}% \draw[\HistoEptraits,->,>=latex] ({\HistoDebX},0) -- ({\HistoFinX},0) --++ ({\HistoElargirx},0) node[right,font=\HistoFonte] {\HistoLabelx} ; \draw[\HistoEptraits,->,>=latex] ({\HistoDebX},0) -- ({\HistoDebX},{\maxhauteurs}) --++ (0,{\HistoElargiry}) node[above,font=\HistoFonte] {\HistoLabely} ; \end{tikzpicture}% }% } \NewDocumentCommand\HistogrammeTikz{ O{} m }{% \useKVdefault[histostats]% \setKV[histostats]{#1}% \setsepchar[.]{ ./}% \readlist*\LISTDONNEES{#2}% \setsepchar{,}% \readlist*\LISTCOUL{\HistoCouleurs}% \foreach \i in {1,...,\LISTDONNEESlen} {% \xintifboolexpr{\LISTCOULlen == 1}% {\def\couleurhisto{\HistoCouleurs}}% {\itemtomacro\LISTCOUL[\i]{\couleurhisto}}% \ifboolKV[histostats]{Remplir}% {% \draw[line width=1pt,fill=\couleurhisto,fill opacity=\HistoOpac] ({\LISTDONNEES[\i,1]-\axexOx},0) rectangle ({\LISTDONNEES[\i,2]-\axexOx},{\LISTDONNEES[\i,3]}) ; }% {% \draw[line width=1pt] ({\LISTDONNEES[\i,1]-\axexOx},0) rectangle ({\LISTDONNEES[\i,2]-\axexOx},{\LISTDONNEES[\i,3]}) ; }% }% \ifboolKV[histostats]{AffEffectifs} {% \IfStrEq{\HistoPosEff}{milieu}% {% \foreach \i in {1,...,\LISTDONNEESlen} \draw ({0.5*\LISTDONNEES[\i,1]+0.5*\LISTDONNEES[\i,2]-\axexOx},{0.5*\LISTDONNEES[\i,3]}) node[font=\HistoFonteEff] {\num{\LISTDONNEES[\i,3]}} ; }% {}% \IfStrEq{\HistoPosEff}{bas}% {% \foreach \i in {1,...,\LISTDONNEESlen} \draw ({0.5*\LISTDONNEES[\i,1]+0.5*\LISTDONNEES[\i,2]-\axexOx},{0}) node[above,font=\HistoFonteEff] {\num{\LISTDONNEES[\i,3]}} ; }% {}% \IfStrEq{\HistoPosEff}{haut}% {% \foreach \i in {1,...,\LISTDONNEESlen} \draw ({0.5*\LISTDONNEES[\i,1]+0.5*\LISTDONNEES[\i,2]-\axexOx},{\LISTDONNEES[\i,3]}) node[below,font=\HistoFonteEff] {\num{\LISTDONNEES[\i,3]}} ; }% {}% \IfStrEq{\HistoPosEff}{dessus}% {% \foreach \i in {1,...,\LISTDONNEESlen} \draw ({0.5*\LISTDONNEES[\i,1]+0.5*\LISTDONNEES[\i,2]-\axexOx},{\LISTDONNEES[\i,3]}) node[above,font=\HistoFonteEff] {\num{\LISTDONNEES[\i,3]}} ; }% {}% }% {}% } %%----Courbe ECC %\usetikzlibrary{intersections} % \newcommand\recuptikzxy[3]{% % \tikz@scan@one@point\pgfutil@firstofone#1\relax % \edef#2{\the\pgf@x}% % \edef#3{\the\pgf@y}% % } \defKV[courbeECC]{% Largeur=\def\ecc@larg@graph{#1},% Hauteur=\def\ecc@haut@graph{#1},% PasX=\def\ecc@grille@x{#1},% PasY=\def\ecc@grille@y{#1},% Couleur=\def\ecc@coul@graph{#1},% CouleursParams=\def\ecc@coul@params{#1},% GraduationsX=\def\ecc@gradx@graph{#1},% GraduationsY=\def\ecc@grady@graph{#1},% PoliceAxes=\def\ecc@font@axes{#1},% ElargirAxes=\def\ecc@elarg@axes{#1} } \setKVdefault[courbeECC]{% Largeur=15,% Hauteur=10,% PasX=50,% PasY=50,% Couleur=blue,% AffParams=true,% CouleursParams={CouleurVertForet/red},% GraduationsX={\DonneesXmin},% GraduationsY={0},% PoliceAxes=\normalsize\normalfont,% ElargirOx=true,% ElargirOy=true,% ElargirAxes=3mm } \tikzset{traitsparamecc/.style={line width=1pt,densely dashed}} \tikzset{courbeecc/.style={line width=1pt}} \tikzset{gradsecc/.style={thick}} \tikzset{axesecc/.style={gradsecc,->,>=latex}} \NewDocumentCommand\CourbeECCStylesDefaut{ }{% \tikzset{traitsparamecc/.style={line width=1pt,densely dashed}} \tikzset{courbeecc/.style={line width=1pt}} \tikzset{gradsecc/.style={thick}} \tikzset{axesecc/.style={gradsecc,->,>=latex}} } \NewDocumentCommand\CourbeECC{ O{} m m }{% \restoreKV[courbeECC]% \setKV[courbeECC]{#1}% \IfSubStr{\ecc@coul@params}{/}% {% \StrCut{\ecc@coul@params}{/}{\ecc@coul@quart}{\ecc@coul@med}% }% {% \def\ecc@coul@quart{\ecc@coul@params}\def\ecc@coul@med{\ecc@coul@params}% }% \readlist*\DataClass{#2}% \readlist*\DataEff{#3}% \xdef\DonneesECC{0}% \xintFor* ##1 in {\xintSeq{1}{\DataEfflen}}\do{% \xdef\DonneesTmp{0} \xintFor* ##2 in {\xintSeq{1}{##1}}\do{% \xdef\DonneesTmp{\xintfloateval{\DonneesTmp+\DataEff[##2]}}% }% \xdef\DonneesECC{\DonneesECC,\DonneesTmp}% }% \readlist*\DataECC\DonneesECC% \itemtomacro\DataClass[1]\DonneesXmin% \itemtomacro\DataClass[-1]\DonneesXmax% \itemtomacro\DataECC[-1]\DonneesEffMax% \xdef\UniteGraphiqueX{\xintfloateval{(\ecc@larg@graph)/(\DonneesXmax-\DonneesXmin)}}% \xdef\UniteGraphiqueY{\xintfloateval{(\ecc@haut@graph)/(\DonneesEffMax)}}% \xdef\DonneesListeECC{(\DataClass[1],\DataECC[1])}% \xintFor* ##1 in {\xintSeq{2}{\DataECClen}}\do{% \xdef\DonneesListeECC{\DonneesListeECC--(\DataClass[##1],\DataECC[##1])}% }% %paramètres par interpolation \xintFor* ##1 in {\xintSeq{1}{\DataEfflen}}\do{% \xdef\isuiv{\xinteval{##1+1}}% \xintifboolexpr{\DataECC[##1] < (0.25*\DonneesEffMax) 'and' \DataECC[\isuiv] >= (0.25*\DonneesEffMax)}% {% \xdef\pentetmpECC{(\DataECC[\isuiv]-\DataECC[##1])/(\DataClass[\isuiv]-\DataClass[##1])}%OK \xdef\ValPremQuartile{\xintfloateval{(0.25*\DonneesEffMax+\pentetmpECC*\DataClass[##1]-\DataECC[##1])/(\pentetmpECC)}}% } {}% \xintifboolexpr{\DataECC[##1] < (0.50*\DonneesEffMax) 'and' \DataECC[\isuiv] >= (0.50*\DonneesEffMax)}% {% \xdef\pentetmpECC{(\DataECC[\isuiv]-\DataECC[##1])/(\DataClass[\isuiv]-\DataClass[##1])}%OK \xdef\ValMed{\xintfloateval{(0.50*\DonneesEffMax+\pentetmpECC*\DataClass[##1]-\DataECC[##1])/(\pentetmpECC)}}% } {}% \xintifboolexpr{\DataECC[##1] < (0.75*\DonneesEffMax) 'and' \DataECC[\isuiv] >= (0.75*\DonneesEffMax)}% {% \xdef\pentetmpECC{(\DataECC[\isuiv]-\DataECC[##1])/(\DataClass[\isuiv]-\DataClass[##1])}%OK \xdef\ValTroisQuartile{\xintfloateval{(0.75*\DonneesEffMax+\pentetmpECC*\DataClass[##1]-\DataECC[##1])/(\pentetmpECC)}}% } {}% }% %graphique \begin{tikzpicture}[x=\UniteGraphiqueX cm,y=\UniteGraphiqueY cm] \draw[xstep=\ecc@grille@x,ystep=\ecc@grille@y,thin,lightgray] (\DonneesXmin,0) grid (\DonneesXmax,\DonneesEffMax) ; %modif axes avec pgffor :-( \foreach \valx in \ecc@gradx@graph {% \draw[gradsecc] (\valx,3pt)--++(0,-6pt) node[below,font=\ecc@font@axes] {\num{\valx}} ; } \foreach \valy in \ecc@grady@graph {% \draw[gradsecc] ($({\DonneesXmin},\valy)+(3pt,0)$)--++(-6pt,0) node[left,font=\ecc@font@axes] {\num{\valy}} ; } \ifboolKV[courbeECC]{ElargirOx}% {% \draw[axesecc] (\DonneesXmin,0)--($(\DonneesXmax,0)+(\ecc@elarg@axes,0)$) ; }% {% \draw[axesecc] (\DonneesXmin,0)--(\DonneesXmax,0) ; }% \ifboolKV[courbeECC]{ElargirOy}% {% \draw[axesecc] (\DonneesXmin,0)--($(\DonneesXmin,\DonneesEffMax)+(0,\ecc@elarg@axes)$) ; }% {% \draw[axesecc] (\DonneesXmin,0)--(\DonneesXmin,\DonneesEffMax) ; }% \draw[courbeecc,\ecc@coul@graph] \DonneesListeECC ; \xintFor* ##1 in {\xintSeq{1}{\DataECClen}}\do{% \filldraw[\ecc@coul@graph] (\DataClass[##1],\DataECC[##1]) circle[radius=2pt] ; }% \ifboolKV[courbeECC]{AffParams}% {% \draw[traitsparamecc,\ecc@coul@quart] (\DonneesXmin,{0.25*\DonneesEffMax})--++({\DonneesXmax-\DonneesXmin},0); \draw[traitsparamecc,\ecc@coul@med] (\DonneesXmin,{0.50*\DonneesEffMax})--++({\DonneesXmax-\DonneesXmin},0); \draw[traitsparamecc,\ecc@coul@quart] (\DonneesXmin,{0.75*\DonneesEffMax})--++({\DonneesXmax-\DonneesXmin},0); \draw[traitsparamecc,\ecc@coul@quart] (\ValPremQuartile,{0.25*\DonneesEffMax})--(\ValPremQuartile,0) ; \draw[\ecc@coul@quart,thick,fill=white] (\ValPremQuartile,{0.25*\DonneesEffMax}) circle[radius=2pt] ; \draw[traitsparamecc,\ecc@coul@quart] (\ValTroisQuartile,{0.75*\DonneesEffMax})--(\ValTroisQuartile,0) ; \draw[\ecc@coul@quart,thick,fill=white] (\ValTroisQuartile,{0.75*\DonneesEffMax}) circle[radius=2pt] ; \draw[traitsparamecc,\ecc@coul@med] (\ValMed,{0.5*\DonneesEffMax})--(\ValMed,0) ; \draw[\ecc@coul@med,thick,fill=white] (\ValMed,{0.5*\DonneesEffMax}) circle[radius=2pt] ; }% {}% \end{tikzpicture}% \CourbeECCStylesDefaut% } \NewDocumentEnvironment{EnvCourbeECC}{ O{} m m }% {% \restoreKV[courbeECC]% \setKV[courbeECC]{#1}% \IfSubStr{\ecc@coul@params}{/}% {% \StrCut{\ecc@coul@params}{/}{\ecc@coul@quart}{\ecc@coul@med}% }% {% \def\ecc@coul@quart{\ecc@coul@params}% \def\ecc@coul@med{\ecc@coul@params}% }% \readlist*\DataClass{#2}% \readlist*\DataEff{#3}% \xdef\DonneesECC{0}% \xintFor* ##1 in {\xintSeq{1}{\DataEfflen}}\do{% \xdef\DonneesTmp{0} \xintFor* ##2 in {\xintSeq{1}{##1}}\do{% \xdef\DonneesTmp{\xintfloateval{\DonneesTmp+\DataEff[##2]}}% }% \xdef\DonneesECC{\DonneesECC,\DonneesTmp}% }% \readlist*\DataECC\DonneesECC% \itemtomacro\DataClass[1]\DonneesXmin% \itemtomacro\DataClass[-1]\DonneesXmax% \itemtomacro\DataECC[-1]\DonneesEffMax% \xdef\UniteGraphiqueX{\xintfloateval{(\ecc@larg@graph)/(\DonneesXmax-\DonneesXmin)}}% \xdef\UniteGraphiqueY{\xintfloateval{(\ecc@haut@graph)/(\DonneesEffMax)}}% \xdef\DonneesListeECC{(\DataClass[1],\DataECC[1])}% \xintFor* ##1 in {\xintSeq{2}{\DataECClen}}\do{% \xdef\DonneesListeECC{\DonneesListeECC--(\DataClass[##1],\DataECC[##1])}% }% %paramètres par interpolation \xintFor* ##1 in {\xintSeq{1}{\DataEfflen}}\do{% \xdef\isuiv{\xinteval{##1+1}}% \xintifboolexpr{\DataECC[##1] < (0.25*\DonneesEffMax) 'and' \DataECC[\isuiv] >= (0.25*\DonneesEffMax)}% {% \xdef\pentetmpECC{(\DataECC[\isuiv]-\DataECC[##1])/(\DataClass[\isuiv]-\DataClass[##1])}%OK \xdef\ValPremQuartile{\xintfloateval{(0.25*\DonneesEffMax+\pentetmpECC*\DataClass[##1]-\DataECC[##1])/(\pentetmpECC)}}% } {}% \xintifboolexpr{\DataECC[##1] < (0.50*\DonneesEffMax) 'and' \DataECC[\isuiv] >= (0.50*\DonneesEffMax)}% {% \xdef\pentetmpECC{(\DataECC[\isuiv]-\DataECC[##1])/(\DataClass[\isuiv]-\DataClass[##1])}%OK \xdef\ValMed{\xintfloateval{(0.50*\DonneesEffMax+\pentetmpECC*\DataClass[##1]-\DataECC[##1])/(\pentetmpECC)}}% } {}% \xintifboolexpr{\DataECC[##1] < (0.75*\DonneesEffMax) 'and' \DataECC[\isuiv] >= (0.75*\DonneesEffMax)}% {% \xdef\pentetmpECC{(\DataECC[\isuiv]-\DataECC[##1])/(\DataClass[\isuiv]-\DataClass[##1])}%OK \xdef\ValTroisQuartile{\xintfloateval{(0.75*\DonneesEffMax+\pentetmpECC*\DataClass[##1]-\DataECC[##1])/(\pentetmpECC)}}% } {}% }% %graphique \begin{tikzpicture}[x=\UniteGraphiqueX cm,y=\UniteGraphiqueY cm] \draw[xstep=\ecc@grille@x,ystep=\ecc@grille@y,thin,lightgray] (\DonneesXmin,0) grid (\DonneesXmax,\DonneesEffMax) ; %modif axes avec pgffor :-( \foreach \valx in \ecc@gradx@graph {% \draw[gradsecc] (\valx,3pt)--++(0,-6pt) node[below,font=\ecc@font@axes] {\num{\valx}} ; } \foreach \valy in \ecc@grady@graph {% \draw[gradsecc] ($({\DonneesXmin},\valy)+(3pt,0)$)--++(-6pt,0) node[left,font=\ecc@font@axes] {\num{\valy}} ; } \ifboolKV[courbeECC]{ElargirOx}% {% \draw[axesecc] (\DonneesXmin,0)--($(\DonneesXmax,0)+(\ecc@elarg@axes,0)$) ; }% {% \draw[axesecc] (\DonneesXmin,0)--(\DonneesXmax,0) ; }% \ifboolKV[courbeECC]{ElargirOy}% {% \draw[axesecc] (\DonneesXmin,0)--($(\DonneesXmin,\DonneesEffMax)+(0,\ecc@elarg@axes)$) ; }% {% \draw[axesecc] (\DonneesXmin,0)--(\DonneesXmin,\DonneesEffMax) ; }% \draw[courbeecc,\ecc@coul@graph] \DonneesListeECC ; \xintFor* ##1 in {\xintSeq{1}{\DataECClen}}\do{% \filldraw[\ecc@coul@graph] (\DataClass[##1],\DataECC[##1]) circle[radius=2pt] ; }% \ifboolKV[courbeECC]{AffParams}% {% \draw[traitsparamecc,\ecc@coul@quart] (\DonneesXmin,{0.25*\DonneesEffMax})--++({\DonneesXmax-\DonneesXmin},0); \draw[traitsparamecc,\ecc@coul@med] (\DonneesXmin,{0.50*\DonneesEffMax})--++({\DonneesXmax-\DonneesXmin},0); \draw[traitsparamecc,\ecc@coul@quart] (\DonneesXmin,{0.75*\DonneesEffMax})--++({\DonneesXmax-\DonneesXmin},0); \draw[traitsparamecc,\ecc@coul@quart] (\ValPremQuartile,{0.25*\DonneesEffMax})--(\ValPremQuartile,0) ; \draw[\ecc@coul@quart,thick,fill=white] (\ValPremQuartile,{0.25*\DonneesEffMax}) circle[radius=2pt] ; \draw[traitsparamecc,\ecc@coul@quart] (\ValTroisQuartile,{0.75*\DonneesEffMax})--(\ValTroisQuartile,0) ; \draw[\ecc@coul@quart,thick,fill=white] (\ValTroisQuartile,{0.75*\DonneesEffMax}) circle[radius=2pt] ; \draw[traitsparamecc,\ecc@coul@med] (\ValMed,{0.5*\DonneesEffMax})--(\ValMed,0) ; \draw[\ecc@coul@med,thick,fill=white] (\ValMed,{0.5*\DonneesEffMax}) circle[radius=2pt] ; }% {}% % \path[name intersections={of=CourbeECC and Quartile1,by=Q1}]; % \path[name intersections={of=CourbeECC and Mediane,by=Q2}]; % \path[name intersections={of=CourbeECC and Quartile3,by=Q3}]; % \recuptikzxy{(Q1)}{\xqun}{\yqun}% % \xdef\ValPremQuartile{\xintfloateval{(0.03515*\fpeval{\xqun})/\UniteGraphiqueX}}% % \recuptikzxy{(Q2)}{\xmediane}{\ymediane} % \xdef\ValMed{\xintfloateval{(0.03515*\fpeval{\xmediane})/\UniteGraphiqueX}}% % \recuptikzxy{(Q3)}{\xqtrois}{\yqtrois}% % \xdef\ValTroisQuartile{\xintfloateval{(0.03515*\fpeval{\xqtrois})/\UniteGraphiqueX}}% }% {% \end{tikzpicture}% \CourbeECCStylesDefaut% } %détermination 'simple' des paramètres \NewDocumentCommand\MedianeQuartilesECC{ m m }{% %lecture des listes \readlist*\DataClass{#1}% \readlist*\DataEff{#2}% %création etlecture de la liste des ECC \xdef\DonneesECC{0}% \xintFor* ##1 in {\xintSeq{1}{\DataEfflen}}\do{% \xdef\DonneesTmp{0}% \xintFor* ##2 in {\xintSeq{1}{##1}}\do{% \xdef\DonneesTmp{\xintfloateval{\DonneesTmp+\DataEff[##2]}}% }% \xdef\DonneesECC{\DonneesECC,\DonneesTmp}% }% \readlist*\DataECC\DonneesECC% %effectif total + nb \itemtomacro\DataECC[-1]\DonneesEffMax% %détermination de Q1, par balayage + par interpolation \xintFor* ##1 in {\xintSeq{1}{\DataEfflen}}\do{% \xdef\isuiv{\xinteval{##1+1}}% \xintifboolexpr{\DataECC[##1] < (0.25*\DonneesEffMax) 'and' \DataECC[\isuiv] >= (0.25*\DonneesEffMax)}% {% \xdef\pentetmpECC{(\DataECC[\isuiv]-\DataECC[##1])/(\DataClass[\isuiv]-\DataClass[##1])}%OK \xdef\ValPremQuartile{\xintfloateval{(0.25*\DonneesEffMax+\pentetmpECC*\DataClass[##1]-\DataECC[##1])/(\pentetmpECC)}}% } {}% \xintifboolexpr{\DataECC[##1] < (0.50*\DonneesEffMax) 'and' \DataECC[\isuiv] >= (0.50*\DonneesEffMax)}% {% \xdef\pentetmpECC{(\DataECC[\isuiv]-\DataECC[##1])/(\DataClass[\isuiv]-\DataClass[##1])}%OK \xdef\ValMed{\xintfloateval{(0.50*\DonneesEffMax+\pentetmpECC*\DataClass[##1]-\DataECC[##1])/(\pentetmpECC)}}% } {}% \xintifboolexpr{\DataECC[##1] < (0.75*\DonneesEffMax) 'and' \DataECC[\isuiv] >= (0.75*\DonneesEffMax)}% {% \xdef\pentetmpECC{(\DataECC[\isuiv]-\DataECC[##1])/(\DataClass[\isuiv]-\DataClass[##1])}%OK \xdef\ValTroisQuartile{\xintfloateval{(0.75*\DonneesEffMax+\pentetmpECC*\DataClass[##1]-\DataECC[##1])/(\pentetmpECC)}}% } {}% }% } \endinput