% tkz-grapheur-fr.tex
% Copyright 2026 Cédric Pierquet
% Released under the LaTeX Project Public License v1.3c or later, see http://www.latex-project.org/lppl.txt
% macros [fr] de tkz-grapheur-fr

%\makeatletter

%====COMMANDE POUR NB DECIMAL ALEA ENTRE BORNES 
\NewDocumentCommand\ChoisirNbAlea{ s O{0} m m O{\monbnalea} }{%
  \def\tmpborneinf{\xinteval{floor(#3)}}%
  \def\tmpbornesup{\xinteval{ceil(#4)}}%
  \xintifboolexpr{#2 == 0}%
    {%
      \xdef#5{\fpeval{randint(\tmpborneinf,\tmpbornesup)}}%
    }%
    {%
      \def\tmptest{0}%
      \whiledo{\tmptest=0}{%
        \xintifboolexpr{(\tmpbornesup-\tmpborneinf) == 1}%
          {%
            \xdef\tmpresalea{\fpeval{\tmpborneinf+round(rand(),#2)}}%
          }%
          {%
            \xdef\tmpresalea{\fpeval{round(randint(\tmpborneinf,\tmpbornesup)+rand(),#2)}}%
          }%
        \IfBooleanTF{#1}%
          {%
            \xintifboolexpr{\tmpresalea < #4 'and' \tmpresalea > #3 }{\def\tmptest{1}}{\def\tmptest{0}}%
          }%
          {%
            \xintifboolexpr{\tmpresalea <= #4 'and' \tmpresalea >= #3 }{\def\tmptest{1}}{\def\tmptest{0}}%
          }%
      }%
      \xdef#5{\tmpresalea}%
    }%
}

%====PATCH NUM
\@ifundefined{ArrondirNum}%
  {%
    \NewDocumentCommand\ArrondirNum{ s O{2} m}{%
      \IfBooleanTF{#1}%
        {%
          \xintfloateval{round(#3,#2)}\relax%
        }%
        {%
          \num{\xintfloateval{round(#3,#2)}}\relax%
        }%
    }%
  }%
  {%
    \RenewDocumentCommand\ArrondirNum{ s O{2} m}{%
      \IfBooleanTF{#1}%
        {%
          \xintfloateval{round(#3,#2)}\relax%
        }%
        {%
          \num{\xintfloateval{round(#3,#2)}}\relax%
        }%
    }%
  }%

%===COMMANDE INTERNE POUR FORMATER EN FRACTIONS
\NewDocumentCommand\FormatterFraction{ s O{} m }{%
  %*=moins sur le numérateur
  %2=argument.optionnel[d/t/dec=...]
  %3=argument mandataire {calcul ou fraction}
  \def\calculargument{\xintPRaw{\xintIrr{\xinteval{#3}}}}%on calcule et on transforme en A/B
  \IfSubStr{\calculargument}{/}%on teste si le symbole / apparaît
  {%si oui := fraction
    \StrBefore{\calculargument}{/}[\numerateur]%on extrait le numérateur
    \StrBehind{\calculargument}{/}[\denominateur]%on extrait le dénominateur
    \ifblank{#2}%
    {%
      \IfBooleanTF{#1}%
      {\ensuremath{\frac{\num{\numerateur}}{\num{\denominateur}}}}%
      {%
        \ifthenelse{\numerateur < 0}%
          {\ensuremath{-\frac{\num{\fpeval{abs(\numerateur)}}}{\num{\denominateur}}}}%
          {\ensuremath{\frac{\num{\numerateur}}{\num{\denominateur}}}}%
      }%
    }%
    {}%si l'argument optionnel est vide
    \IfStrEq{#2}{d}%
    {%
      \IfBooleanTF{#1}%
      {\ensuremath{\displaystyle\frac{\num{\numerateur}}{\num{\denominateur}}}}%
      {%
        \ifthenelse{\numerateur < 0}%
          {\ensuremath{-\displaystyle\frac{\num{\fpeval{abs(\numerateur)}}}{\num{\denominateur}}}}%
          {\ensuremath{\displaystyle\frac{\num{\numerateur}}{\num{\denominateur}}}}%
      }%
    }%
    {}%si l'argument optionnel est vide
    \IfStrEq{#2}{t}%
    {%
      \IfBooleanTF{#1}%
      {\ensuremath{\tfrac{\num{\numerateur}}{\num{\denominateur}}}}%
      {%
        \ifthenelse{\numerateur < 0}%
          {\ensuremath{-\frac{\num{\fpeval{abs(\numerateur)}}}{\num{\denominateur}}}}%
          {\ensuremath{\frac{\num{\numerateur}}{\num{\denominateur}}}}%
      }%
    }%
    {}%si l'argument optionnel est vide
    \IfStrEq{#2}{n}%
    {%
      \ensuremath{\nicefrac{\num{\numerateur}}{\num{\denominateur}}}%
    }%
    {}%si l'argument optionnel est vide
  }{%si non := entier
    \num{\calculargument}%on affiche l'entier, avec le package siunitx
  }%
}

%affichage d'un label en radians
\NewDocumentCommand\FormatterTrigo{ O{t} m }{%étoilée en dfrac
  \IfStrEq{#2}{0}%cas où l'argument vaut 0
    {\def\restmp{0}}%
    {%
      \StrDel{#2}{*}[\restmpsansmoins]%
      \StrSubstitute{\restmpsansmoins}{pi}{\pi}[\restmppi]%
      \IfSubStr{#2}{/}%
      {%
        \StrCut{\restmppi}{/}\tmpnum\tmpdenom%
        \IfSubStr{\tmpnum}{-}%
        {%
          \StrDel{\tmpnum}{-}[\restmppinum]%
          \IfStrEqCase{#1}{%
            {t}{\def\restmp{-\frac{\restmppinum}{\tmpdenom}}}%
            {d}{\def\restmp{-\displaystyle\frac{\restmppinum}{\tmpdenom}}}%
            {n}{\def\restmp{\nicefrac{-\restmppinum}{\tmpdenom}}}%
          }%
        }%
        {%
          \IfStrEqCase{#1}{%
            {t}{\def\restmp{\frac{\tmpnum}{\tmpdenom}}}%
            {d}{\def\restmp{\displaystyle\frac{\tmpnum}{\tmpdenom}}}%
            {n}{\def\restmp{\nicefrac{\tmpnum}{\tmpdenom}}}%
          }%
        }%
      }%
      {%
        \def\restmp{\restmppi}%
      }%
    }%
  \ensuremath{\restmp}%
}

%====FORMATAGE DES RACINES SIMPLES
\NewDocumentCommand\FormatterRacine{ O{t} m }{%
  \IfStrEq{#2}{0}%cas où l'argument vaut 0
    {\ensuremath{0}}%
    {%
      \IfSubStr{#2}{sqrt}%
        {%
          \StrDel{#2}{*}[\tmpargbrut]%
          \StrBetween[1,1]{\tmpargbrut}{sqrt(}{)}[\tmpargnumrac]%
          \StrBefore{\tmpargbrut}{sqrt}[\tmparavantrac]%
          \IfStrEqCase{\tmparavantrac}{
            {}{\xdef\tmparavantrac{}}%
            {-}{\xdef\tmparavantrac{-}}%
          }[\xdef\tmparavantrac{\num{\tmparavantrac}}]%
          \IfSubStr{\tmpargbrut}{/}%
            {%
              \StrBehind{\tmpargbrut}{/}[\tmpargdenomrac]%
              \IfStrEqCase{#1}{%
                {d}{%
                  \ensuremath{\displaystyle\frac{\tmparavantrac\sqrt{\num{\tmpargnumrac}}}{\num{\tmpargdenomrac}}}%
                }%
                {t}{%
                  \ensuremath{\frac{\tmparavantrac\sqrt{\num{\tmpargnumrac}}}{\num{\tmpargdenomrac}}}%
                }%
                {n}{%
                  \ensuremath{\nicefrac{\tmparavantrac\sqrt{\num{\tmpargnumrac}}}{\num{\tmpargdenomrac}}}%
                }%
              }%
            }%
            {%
              \ensuremath{\tmparavantrac\sqrt{\num{\tmpargnumrac}}}%
            }%
        }%
        {%
          \FormatterFraction[#1]{#2}%
        }%
    }%
}

%====COMMANDE INTERNE DE CONVERSION
\ExplSyntaxOn
  \NewDocumentCommand\ConvertirPtToCm{ m } { \dim_to_decimal_in_unit:nn { #1 } { 1 cm } }
\ExplSyntaxOff

%====RECUPERER COORDONNEES NOEUD
\NewDocumentCommand\RecupererAbscisse{ m O{\monabs} }{%
  \path #1;
  \pgfgetlastxy{\macrox}{\macroy}%
  \xdef#2{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
}
\NewDocumentCommand\RecupererOrdonnee{ m O{\monordo} }{%
  \path #1;
  \pgfgetlastxy{\macrox}{\macroy}%
  \xdef#2{\xintfloateval{(\ConvertirPtToCm{\macroy})/(\pflyunit)}}%
}

\NewDocumentCommand\RecupererCoordonnees{ m O{\monabs} O{\monordo} }{%
  \RecupererAbscisse{#1}[#2]%
  \RecupererOrdonnee{#1}[#3]%
}

%===UNITÉS
\newcommand\DistanceEntreNoeuds[3][\MyTmpDist]{%
    \pgfpointdiff{\pgfpointanchor{#2}{center}}
                 {\pgfpointanchor{#3}{center}}
    % no need to use a new dimen
    \pgf@xa=\pgf@x
    \pgf@ya=\pgf@y
    % to convert from pt to cm   
    \pgfmathparse{veclen(\pgf@xa,\pgf@ya)/28.45274}
    \global\let#1\pgfmathresult %macro globale
}

\newcommand\TikZUnites{
    \coordinate (@0) at (\pflOx,\pflOy) ;
    \coordinate (@X) at ({\pflOx+1},\pflOy) ;
    \coordinate (@Y) at ({\pflOx},{\pflOy+1}) ;
    \DistanceEntreNoeuds[\pflxunit]{@0}{@X}
    \DistanceEntreNoeuds[\pflyunit]{@0}{@Y}
}

\defKV[GraphiqueTikz]{%
  TailleGrad=\setlength\pflthickgrad{#1},%
  Xmin=\def\pflxmintmp{#1},%
  Xmax=\def\pflxmaxtmp{#1},%
  Ymin=\def\pflymintmp{#1},%
  Ymax=\def\pflymaxtmp{#1},%
  Taille=\def\pflgraphdims{#1},%
  Theme=\def\pflgraphthem{#1},%
  NomFigure=\def\pflgraphnom{#1}
}
\setKVdefault[GraphiqueTikz]{%
  AffCadre=false,%
  TailleGrad=3pt,%
  Xmin=-3,%
  Xmax=3,%
  Ymin=-3,%
  Ymax=3,%
  Taille={},%
  Theme={},
  Milli=false,%
  NomFigure={}
}

\NewDocumentEnvironment{GraphiqueTikz}{ O{} D<>{} }%
%1 = options tikz, classiques
%2 = clés spécifiques
{%
  \restoreKV[GraphiqueTikz]%
  \setKV[GraphiqueTikz]{#2}%
  %l'environnement
  \IfStrEq{\pflgraphdims}{}%
    {%
      \begin{tikzpicture}[#1]%
    }%
    {%
      \StrCut{\pflgraphdims}{/}{\pfltmpwidth}{\pfltmpheight}%
      \setlength\pflglobalwidth{\fpeval{(\pfltmpwidth)/(\pflxmaxtmp-\pflxmintmp)}pt}%\the\pflglobalwidth+%
      \setlength\pflglobalheight{\fpeval{(\pfltmpheight)/(\pflymaxtmp-\pflymintmp)}pt}%\the\pflglobalheight%
      \begin{tikzpicture}[x=\pflglobalwidth,y=\pflglobalheight,Xmin=\pflxmintmp,Xmax=\pflxmaxtmp,Ymin=\pflymintmp,Ymax=\pflymaxtmp,#1]%
    }%
  %thèmes personnalisés
  \IfStrEqCase{\pflgraphthem}{%
    {standard}{\tikzset{pflgrillep/.style={line width=0.75pt,pflgrillepdefault!75}}\tikzset{pflgrilles/.style={line width=0.25pt,pflgrillesdefault}}\tikzset{pflgrillei/.style={line width=0.5pt,pflgrilleidefault}}}%
    {gris}{\tikzset{pflgrillep/.style={line width=0.75pt,pflgrillepgray!75}}\tikzset{pflgrilles/.style={line width=0.25pt,pflgrillesgray}}\tikzset{pflgrillei/.style={line width=0.5pt,pflgrilleigray}}}%
    {bleu}{\tikzset{pflgrillep/.style={line width=0.75pt,pflgrillepblue!75}}\tikzset{pflgrilles/.style={line width=0.25pt,pflgrillesblue}}\tikzset{pflgrillei/.style={line width=0.5pt,pflgrilleiblue}}}%
    {vert}{\tikzset{pflgrillep/.style={line width=0.75pt,pflgrillepgreen!75}}\tikzset{pflgrilles/.style={line width=0.25pt,pflgrillesgreen}}\tikzset{pflgrillei/.style={line width=0.5pt,pflgrilleigreen}}}%
    {chaud}{\tikzset{pflgrillep/.style={line width=0.75pt,pflgrillepwarm!75}}\tikzset{pflgrilles/.style={line width=0.25pt,pflgrilleswarm}}\tikzset{pflgrillei/.style={line width=0.5pt,pflgrilleiwarm}}}%
    {contraste}{\tikzset{pflgrillep/.style={line width=0.75pt,pflgrillepcontrast!75}}\tikzset{pflgrilles/.style={line width=0.25pt,pflgrillescontrast}}\tikzset{pflgrillei/.style={line width=0.5pt,pflgrilleicontrast}}}%
  }%
  %unités x/y pour des calculs de coordonnées
  \TikZUnites
  %noeuds fenêtre + axes
  \IfStrEq{\pflgraphnom}{}%
    {%
      \coordinate (graphe-ne) at ({\pflxmax},{\pflymax}) ;
      \coordinate (graphe-nw) at ({\pflxmin},{\pflymax}) ;
      \coordinate (graphe-se) at ({\pflxmax},{\pflymin}) ;
      \coordinate (graphe-sw) at ({\pflxmin},{\pflymin}) ;
      \coordinate (graphe-n) at ($(graphe-ne)!0.5!(graphe-nw)$) ;
      \coordinate (graphe-e) at ($(graphe-ne)!0.5!(graphe-se)$) ;
      \coordinate (graphe-s) at ($(graphe-se)!0.5!(graphe-sw)$) ;
      \coordinate (graphe-w) at ($(graphe-sw)!0.5!(graphe-nw)$) ;
      \coordinate (graphe-c) at ($(graphe-sw)!0.5!(graphe-ne)$) ;
      \coordinate (axeox-w) at ({\pflxmin},{\pflOy}) ;
      \coordinate (axeox-e) at ({\pflxmax},{\pflOy}) ;
      \coordinate (axeoy-s) at ({\pflOx},{\pflymin}) ;
      \coordinate (axeoy-n) at ({\pflOx},{\pflymax}) ;
      \coordinate (axes-orig) at ({\pflOx},{\pflOy}) ;
    }%
    {%
      \coordinate (\pflgraphnom-graphe-ne) at ({\pflxmax},{\pflymax}) ;
      \coordinate (\pflgraphnom-graphe-nw) at ({\pflxmin},{\pflymax}) ;
      \coordinate (\pflgraphnom-graphe-se) at ({\pflxmax},{\pflymin}) ;
      \coordinate (\pflgraphnom-graphe-sw) at ({\pflxmin},{\pflymin}) ;
      \coordinate (\pflgraphnom-graphe-n) at ($(\pflgraphnom-graphe-ne)!0.5!(\pflgraphnom-graphe-nw)$) ;
      \coordinate (\pflgraphnom-graphe-e) at ($(\pflgraphnom-graphe-ne)!0.5!(\pflgraphnom-graphe-se)$) ;
      \coordinate (\pflgraphnom-graphe-s) at ($(\pflgraphnom-graphe-se)!0.5!(\pflgraphnom-graphe-sw)$) ;
      \coordinate (\pflgraphnom-graphe-w) at ($(\pflgraphnom-graphe-sw)!0.5!(\pflgraphnom-graphe-nw)$) ;
      \coordinate (\pflgraphnom-graphe-c) at ($(\pflgraphnom-graphe-sw)!0.5!(\pflgraphnom-graphe-ne)$) ;
      \coordinate (\pflgraphnom-axeox-w) at ({\pflxmin},{\pflOy}) ;
      \coordinate (\pflgraphnom-axeox-e) at ({\pflxmax},{\pflOy}) ;
      \coordinate (\pflgraphnom-axeoy-s) at ({\pflOx},{\pflymin}) ;
      \coordinate (\pflgraphnom-axeoy-n) at ({\pflOx},{\pflymax}) ;
      \coordinate (\pflgraphnom-axes-orig) at ({\pflOx},{\pflOy}) ;
    }%
    %noeuds utiles pour les calculs
    \coordinate (bbxTop) at (current bounding box.north) ;
    \coordinate (bbxBottom) at (current bounding box.south) ;
    \ifboolKV[GraphiqueTikz]{AffCadre}{\draw[pflcadre] ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax}) ;}{}%
    %back to normal
}%
{%
  \end{tikzpicture}%
}

%====AXES
\defKV[GraphiqueTikzAxes]{
  Format=\def\pflformataxes{#1}
}
\setKVdefault[GraphiqueTikzAxes]{%
  Grille=true,%
  Grille Intermediaire=false,%
  Elargir=0,%
  Grads=true,%
  Origine=false,%
  Police={},%
  Format=num,%
  Traits=true,%
  Dernier=false,%
  Derriere=false,%
  Devant=false,%
  Fleches=true
}

\NewDocumentCommand\FormatterValeurAxex{ m m }{%
  \IfStrEqCase{#1}{%
    {num}{\num{#2}}%
    {annee}{#2}%
    {frac}{\FormatterFraction{#2}}%
    {dfrac}{\FormatterFraction[d]{#2}}%
    {nfrac}{\FormatterFraction[n]{#2}}%
    {trig}{\FormatterTrigo{#2}}%
    {dtrig}{\FormatterTrigo[d]{#2}}%
    {ntrig}{\FormatterTrigo[n]{#2}}%
    {sqrt}{\FormatterRacine{#2}}%
    {dsqrt}{\FormatterRacine[d]{#2}}%
    {nsqrt}{\FormatterRacine[n]{#2}}%
  }[#2]%
}

\NewDocumentCommand\FormatterValeurAxey{ m m }{%
  \IfStrEqCase{#1}{%
    {num}{\num{#2}}%
    {annee}{#2}%
    {frac}{\FormatterRacine{#2}}%
    {dfrac}{\FormatterFraction[d]{#2}}%
    {nfrac}{\FormatterFraction[n]{#2}}%
    {trig}{\FormatterTrigo{#2}}%
    {dtrig}{\FormatterTrigo[d]{#2}}%
    {ntrig}{\FormatterTrigo[n]{#2}}%
    {sqrt}{\FormatterRacine{#2}}%
    {dsqrt}{\FormatterRacine[d]{#2}}%
    {nsqrt}{\FormatterRacine[n]{#2}}%
  }[#2]%
}

\NewDocumentCommand\TracerAxesGrilles{ s O{} m D<>{#3} m D<>{#5} }{%
  \restoreKV[GraphiqueTikzAxes]%
  \setKV[GraphiqueTikzAxes]{#2}%
  %nœuds axes élargis
  \IfStrEq{\pflgraphnom}{}%
  {%
    \coordinate (axeox-ee) at ([xshift={\useKV[GraphiqueTikzAxes]{Elargir}}]{\pflxmax},{\pflOy}) ;
    \coordinate (axeoy-nn) at ([yshift={\useKV[GraphiqueTikzAxes]{Elargir}}]{\pflOx},{\pflymax}) ;
  }%
  {%
    \coordinate (\pflgraphnom-axeox-ee) at ([xshift={\useKV[GraphiqueTikzAxes]{Elargir}}]{\pflxmax},{\pflOy}) ;
    \coordinate (\pflgraphnom-axeoy-nn) at ([yshift={\useKV[GraphiqueTikzAxes]{Elargir}}]{\pflOx},{\pflymax}) ;
  }%
  %cas particuliers sous/sur impression
  \ifboolKV[GraphiqueTikzAxes]{Derriere}%
    {%
      \setKV[GraphiqueTikzAxes]{Grads=false}
    }%
    {}%
  \ifboolKV[GraphiqueTikzAxes]{Devant}%
    {%
      \setKV[GraphiqueTikzAxes]{Grille=false}
    }%
    {}%
  %suite
  \IfSubStr{\pflformataxes}{/}%
    {%
      \StrCut{\pflformataxes}{/}{\pflformataxex}{\pflformataxey}%
    }%
    {%
      \xdef\pflformataxex{\pflformataxes}\xdef\pflformataxey{\pflformataxes}%
    }%
  \ifboolKV[GraphiqueTikzAxes]{Grille}%
    {%
      \ifboolKV[GraphiqueTikz]{Milli}%
        {%
          \draw[pflgrilles,xstep=\fpeval{0.1*\pflgrillex},ystep=\fpeval{0.1*\pflgrilley}] ({\pflxmin},{\pflymin}) grid ({\pflxmax},{\pflymax});
          \draw[pflgrillei,xstep=\fpeval{0.5*\pflgrillex},ystep=\fpeval{0.5*\pflgrilley}] ({\pflxmin},{\pflymin}) grid ({\pflxmax},{\pflymax});
        }%
        {%
          \draw[pflgrilles,xstep=\pflgrillexs,ystep=\pflgrilleys] ({\pflxmin},{\pflymin}) grid ({\pflxmax},{\pflymax});
        }%
        \ifboolKV[GraphiqueTikzAxes]{Grille Intermediaire}%
          {%
            \draw[pflgrillei,xstep=\pflgrillexi,ystep=\pflgrilleyi] ({\pflxmin},{\pflymin}) grid ({\pflxmax},{\pflymax});
          }%
          {}%
      \draw[pflgrillep,xstep=\pflgrillex,ystep=\pflgrilley] ({\pflxmin},{\pflymin}) grid ({\pflxmax},{\pflymax});
      \ifboolKV[GraphiqueTikzAxes]{Dernier}%
        {%
          \draw[pflgrillep] ({\pflxmin},{\pflymax})--({\pflxmax},{\pflymax}) ;
          \draw[pflgrillep] ({\pflxmax},{\pflymin})--({\pflxmax},{\pflymax}) ;
        }%
        {}%
    }%
    {}%
  %axes
  \ifboolKV[GraphiqueTikzAxes]{Fleches}%
    {%
      \draw[pflaxes] ({\pflxmin},{\pflOy}) -- ([xshift={\useKV[GraphiqueTikzAxes]{Elargir}}]{\pflxmax},{\pflOy}) ;
      \draw[pflaxes] ({\pflOx},{\pflymin}) -- ([yshift={\useKV[GraphiqueTikzAxes]{Elargir}}]{\pflOx},{\pflymax}) ;
    }%
    {%
      \draw[pflaxessansfleche] ({\pflxmin},{\pflOy}) -- ([xshift={\useKV[GraphiqueTikzAxes]{Elargir}}]{\pflxmax},{\pflOy}) ;
      \draw[pflaxessansfleche] ({\pflOx},{\pflymin}) -- ([yshift={\useKV[GraphiqueTikzAxes]{Elargir}}]{\pflOx},{\pflymax}) ;
    }%
  \IfEq{#3}{auto}%
    {%
      \xdef\tmprangexvalues{\xintfloateval{seq(i,i=\pflxmin..[\pflgrillex]..\pflxmax)}}\StrDel{\tmprangexvalues}{ }[\tmprangexvalues]%
      \xdef\pflformataxex{num}%
    }%
    {%
      \xdef\tmprangexvalues{#3}%
    }%
  \IfEq{#5}{auto}%
    {%
      \xdef\tmprangeyvalues{\xintfloateval{seq(i,i=\pflymin..[\pflgrilley]..\pflymax)}}\StrDel{\tmprangeyvalues}{ }[\tmprangeyvalues]%
      \xdef\pflformataxey{num}%
    }%
    {%
      \xdef\tmprangeyvalues{#5}%
    }%
  \foreach \x in \tmprangexvalues {\draw[pfltrait] ([yshift=\pflthickgrad]{\x},{\pflOy})--++(0,{-2\pflthickgrad}) ;}
  \foreach \y in \tmprangeyvalues {\draw[pfltrait] ([xshift=\pflthickgrad]{\pflOx},{\y})--++({-2\pflthickgrad},0) ;}
  \ifboolKV[GraphiqueTikzAxes]{Grads}%
    {%
      %origine
      \ifboolKV[GraphiqueTikzAxes]{Origine}%
        {%
          \draw ({\pflOx},{\pflOy}) node[pflnoeud,below left,font={\useKV[GraphiqueTikzAxes]{Police}}] {\FormatterValeurAxex{\pflformataxex}{\pflOx}} ;
        }%
        {}%
      %graduations x, sauf si auto...
      \foreach \x in \tmprangexvalues {%
        \IfBooleanTF{#1}%
          {%
            \xintifboolexpr{\x == \pflOx}{}{\draw ([yshift={-\pflthickgrad}]{\x},{\pflOy}) node[pflnoeud,below,font={\useKV[GraphiqueTikzAxes]{Police}}] {\FormatterValeurAxex{\pflformataxex}{\x}} ;}
          }%
          {%
            \draw ([yshift={-\pflthickgrad}]{\x},{\pflOy}) node[pflnoeud,below,font={\useKV[GraphiqueTikzAxes]{Police}}] {\FormatterValeurAxex{\pflformataxex}{\x}} ;
          }%
        }%
      \foreach \y in \tmprangeyvalues {%
        \IfBooleanTF{#1}%
          {%
            \xintifboolexpr{\y == \pflOy}{}{\draw ([xshift={-\pflthickgrad}]{\pflOx},{\y}) node[pflnoeud,left,font={\useKV[GraphiqueTikzAxes]{Police}}] {\FormatterValeurAxey{\pflformataxey}{\y}} ;}
          }%
          {%
            \draw ([xshift={-\pflthickgrad}]{\pflOx},{\y}) node[pflnoeud,left,font={\useKV[GraphiqueTikzAxes]{Police}}] {\FormatterValeurAxey{\pflformataxey}{\y}} ;
          }%
        }%
    }%
    {}%
}

\NewDocumentCommand\TracerAxesGrillePol{ O{} m m }{%
  \restoreKV[GraphiqueTikzAxes]%
  \setKV[GraphiqueTikzAxes]{#1}%
  %cercles secondaires
  \foreach \r in {\pflpolgrids,\fpeval{2*\pflpolgrids},...,\pflpolrayonmax}{%
    \draw[pflgrilles] (0,0) circle[radius=\r] ;
  }%
  %cercles ppaux
  \foreach \r in {\pflpolgrid,\fpeval{2*\pflpolgrid},...,\pflpolrayonmax}{%
    \draw[pflgrillep] (0,0) circle[radius=\r] ;
  }%
  %droites radiales secondaires
  \foreach \a in {0,\pflgrillets,...,180}{%
    \draw[pflgrilles] ({-(\pflpolrayonmax)*cos(\a)},{-(\pflpolrayonmax)*sin(\a)}) -- 
    ({(\pflpolrayonmax)*cos(\a)},{(\pflpolrayonmax)*sin(\a)}) ;
  }%
  %droites radiales ppales
  \foreach \a in {0,\pflgrillet,...,180}{%
    \draw[pflgrillep] ({-(\pflpolrayonmax)*cos(\a)},{-(\pflpolrayonmax)*sin(\a)}) -- 
    ({(\pflpolrayonmax)*cos(\a)},{(\pflpolrayonmax)*sin(\a)}) ;
  }%
  %ensuite les axes, via la macro principale
  \TracerAxesGrilles[#1,Grille=false]{#2}{#3}
}

%===DEFINIR POINTS
\setKVdefault[GraphiqueTikzDefPoints]{Couleur=black,Aff=false,Style=o}

\NewDocumentCommand\DefinirPts{ O{} m }{%
  \restoreKV[GraphiqueTikzDefPoints]%
  \setKV[GraphiqueTikzDefPoints]{#1}%
  \foreach \tmpnamept/\tmpxpt/\tmpypt in {#2}{%
  \coordinate (\tmpnamept) at ({\tmpxpt},{\tmpypt}) ;
    \ifboolKV[GraphiqueTikzDefPoints]{Aff}%
      {%
        \MarquerPts*[Style={\useKV[GraphiqueTikzDefPoints]{Style}},Couleur={\useKV[GraphiqueTikzDefPoints]{Couleur}}]{(\tmpnamept)}
      }%
      {}%
  }
}

\defKV[GraphiqueTikzMarkPoints]{%
  Couleur=\def\pflcouleurpoints{#1},%
  Style=\def\pflstylepoints{#1}
}
\setKVdefault[GraphiqueTikzMarkPoints]{%
  Couleur=black,%
  Taillec=2pt,%
  Taillex=2pt,%
  Tailleo=1.75pt,%
  Style=o,%
  Traits=false
}
\NewDocumentCommand\MarquerPts{ s O{} D<>{\normalfont\normalsize} m }{%
  %étoilée = sans label
  %2=clés
  %3=points
  \restoreKV[GraphiqueTikzMarkPoints]%
  \setKV[GraphiqueTikzMarkPoints]{#2}%
  \IfBooleanTF{#1}%
    {%
      \IfStrEq{\pflstylepoints}{x}%
        {%
          \foreach \Point in {#4} {%
            \ifboolKV[GraphiqueTikzMarkPoints]{Traits}%
              {%
                \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}},pfltraitantec] let \p1 = \Point in ({\x1},{\pflOy}) |- ({\pflOx},{\y1}) ;
              }%
              {}%
            \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}}] \Point pic{pflptcroix={\useKV[GraphiqueTikzMarkPoints]{Taillex}}/45} ;
          }%
        }%
        {}%
      \IfStrEq{\pflstylepoints}{+}%
        {%
          \foreach \Point in {#4} {%
            \ifboolKV[GraphiqueTikzMarkPoints]{Traits}%
              {%
                \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}},pfltraitantec] let \p1 = \Point in ({\x1},{\pflOy}) |- ({\pflOx},{\y1}) ;
              }%
              {}%
            \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}}] \Point pic{pflptcroix={\useKV[GraphiqueTikzMarkPoints]{Taillex}}/90} ;
          }%
        }%
        {}%
      \IfStrEq{\pflstylepoints}{c}%
        {%
          \foreach \Point in {#4} {%
            \ifboolKV[GraphiqueTikzMarkPoints]{Traits}%
              {%
                \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}},pfltraitantec] let \p1 = \Point in ({\x1},{\pflOy}) |- ({\pflOx},{\y1}) ;
              }%
              {}%
            \filldraw[draw=none,fill={\useKV[GraphiqueTikzMarkPoints]{Couleur}}] \Point pic{pflptcarre={\useKV[GraphiqueTikzMarkPoints]{Taillec}}/0} ;
          }%
        }%
        {}%
      \IfStrEq{\pflstylepoints}{d}%
        {%
          \foreach \Point in {#4} {%
            \ifboolKV[GraphiqueTikzMarkPoints]{Traits}%
              {%
                \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}},pfltraitantec] let \p1 = \Point in ({\x1},{\pflOy}) |- ({\pflOx},{\y1}) ;
              }%
              {}%
            \filldraw[draw=none,fill={\useKV[GraphiqueTikzMarkPoints]{Couleur}}] \Point pic{pflptcarre={\useKV[GraphiqueTikzMarkPoints]{Tailleo}}/45} ;
          }%
        }%
        {}%
      \IfStrEq{\pflstylepoints}{o}%
        {%
          \IfSubStr{\pflcouleurpoints}{/}%
            {%
              \StrCut{\pflcouleurpoints}{/}{\pflcouleurpointsA}{\pflcouleurpointsB}%
              \foreach \Point in {#4} {%
                \ifboolKV[GraphiqueTikzMarkPoints]{Traits}%
                  {%
                    \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}},pfltraitantec] let \p1 = \Point in ({\x1},{\pflOy}) |- ({\pflOx},{\y1}) ;
                  }%
                  {}%
                \filldraw[pfltrait,fill=\pflcouleurpointsB,draw=\pflcouleurpointsA] \Point circle[radius={\useKV[GraphiqueTikzMarkPoints]{Tailleo}}] ;
              }%
            }%
            {%
              \foreach \Point in {#4} {%
                \ifboolKV[GraphiqueTikzMarkPoints]{Traits}%
                  {%
                    \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}},pfltraitantec] let \p1 = \Point in ({\x1},{\pflOy}) |- ({\pflOx},{\y1}) ;
                  }%
                  {}%
                \filldraw[\pflcouleurpoints] \Point circle[radius={\useKV[GraphiqueTikzMarkPoints]{Tailleo}}] ;
              }%
            }%
        }%
        {}%
    }%
    {%avec label
      \IfStrEq{\pflstylepoints}{x}%
        {%
          \foreach \Point/\Label/\Pos in {#4} {%
            \ifboolKV[GraphiqueTikzMarkPoints]{Traits}%
              {%
                \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}},pfltraitantec] let \p1 = \Point in ({\x1},{\pflOy}) |- ({\pflOx},{\y1}) ;
              }%
              {}%
            \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}}] \Point pic{pflptcroix={\useKV[GraphiqueTikzMarkPoints]{Taillex}}/45} node[pflnoeud,\Pos,font=#3] {\Label} ;
          }%
        }%
        {}%
      \IfStrEq{\pflstylepoints}{+}%
        {%
          \foreach \Point/\Label/\Pos in {#4} {%
            \ifboolKV[GraphiqueTikzMarkPoints]{Traits}%
              {%
                \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}},pfltraitantec] let \p1 = \Point in ({\x1},{\pflOy}) |- ({\pflOx},{\y1}) ;
              }%
              {}%
            \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}}] \Point pic{pflptcroix={\useKV[GraphiqueTikzMarkPoints]{Taillex}}/90} node[pflnoeud,\Pos,font=#3] {\Label} ;
          }%
        }%
        {}%
      \IfStrEq{\pflstylepoints}{c}%
        {%
          \foreach \Point/\Label/\Pos in {#4} {%
            \ifboolKV[GraphiqueTikzMarkPoints]{Traits}%
              {%
                \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}},pfltraitantec] let \p1 = \Point in ({\x1},{\pflOy}) |- ({\pflOx},{\y1}) ;
              }%
              {}%
            \filldraw[draw=none,fill={\useKV[GraphiqueTikzMarkPoints]{Couleur}}] \Point pic{pflptcarre={\useKV[GraphiqueTikzMarkPoints]{Taillec}}/0} node[pflnoeud,\Pos,{\useKV[GraphiqueTikzMarkPoints]{Couleur}},font=#3] {\Label} ;
          }%
        }%
        {}%
      \IfStrEq{\pflstylepoints}{d}%
        {%
          \foreach \Point/\Label/\Pos in {#4} {%
            \ifboolKV[GraphiqueTikzMarkPoints]{Traits}%
              {%
                \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}},pfltraitantec] let \p1 = \Point in ({\x1},{\pflOy}) |- ({\pflOx},{\y1}) ;
              }%
              {}%
            \filldraw[draw=none,fill={\useKV[GraphiqueTikzMarkPoints]{Couleur}}] \Point pic{pflptcarre={\useKV[GraphiqueTikzMarkPoints]{Tailleo}}/45} node[pflnoeud,\Pos,{\useKV[GraphiqueTikzMarkPoints]{Couleur}},font=#3] {\Label} ;
          }%
        }%
        {}%
      \IfStrEq{\pflstylepoints}{o}%
        {%
          \IfSubStr{\pflcouleurpoints}{/}%
            {%
              \StrCut{\pflcouleurpoints}{/}{\pflcouleurpointsA}{\pflcouleurpointsB}%
              \foreach \Point/\Label/\Pos in {#4} {%
                \ifboolKV[GraphiqueTikzMarkPoints]{Traits}%
                  {%
                    \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}},pfltraitantec] let \p1 = \Point in ({\x1},{\pflOy}) |- ({\pflOx},{\y1}) ;
                  }%
                  {}%
                \draw[pfltrait,\pflcouleurpointsA,fill=\pflcouleurpointsB] \Point circle[radius={\useKV[GraphiqueTikzMarkPoints]{Tailleo}}] node[pflnoeud,\Pos,font=#3] {\Label} ;
              }%
            }%
            {%
              \foreach \Point/\Label/\Pos in {#4} {%
                \ifboolKV[GraphiqueTikzMarkPoints]{Traits}%
                  {%
                    \draw[{\useKV[GraphiqueTikzMarkPoints]{Couleur}},pfltraitantec] let \p1 = \Point in ({\x1},{\pflOy}) |- ({\pflOx},{\y1}) ;
                  }%
                  {}%
                \filldraw[\pflcouleurpoints] \Point circle[radius={\useKV[GraphiqueTikzMarkPoints]{Tailleo}}] node[pflnoeud,\Pos,font=#3] {\Label} ;
              }%
            }%
        }%
        {}%
    }%
}

%===AJOUTER DES VALEURS MANUELLEMENT
\NewDocumentCommand\RajouterValeursAxeX{ O{} m m }{%
  \restoreKV[GraphiqueTikzAxes]%
  \setKV[GraphiqueTikzAxes]{#1}%
  \ifboolKV[GraphiqueTikzAxes]{Traits}{\foreach \x in {#2}{\draw[pfltrait] ([yshift=\pflthickgrad]{\x},{\pflOy})--++(0,{-2\pflthickgrad}) ;}}{}%
  \setsepchar{,}%
  \readlist*\LstValX{#2}%
  \readlist*\LstValFmtX{#3}%
  \foreach \i in {1,...,\LstValXlen}{%
    \itemtomacro\LstValX[\i]\mavalx%
    \itemtomacro\LstValFmtX[\i]\mavalfmtx%
    \draw ([yshift={-\pflthickgrad}]{\mavalx},{\pflOy}) node[pflnoeud,below,font={\useKV[GraphiqueTikzAxes]{Police}}] {\mavalfmtx} ;
  }%
}

\NewDocumentCommand\RajouterValeursAxeY{ O{} m m }{%
  \restoreKV[GraphiqueTikzAxes]%
  \setKV[GraphiqueTikzAxes]{#1}%
  \ifboolKV[GraphiqueTikzAxes]{Traits}{\foreach \y in {#2}{\draw[pfltrait] ([xshift=\pflthickgrad]{\pflOx},{\y})--++({-2\pflthickgrad},0) ;}}{}%
  \setsepchar{,}%
  \readlist*\LstValY{#2}%
  \readlist*\LstValFmtY{#3}%
  \foreach \i in {1,...,\LstValYlen}{%
    \itemtomacro\LstValY[\i]\mavaly%
    \itemtomacro\LstValFmtY[\i]\mavalfmty%
    \draw ([xshift={-\pflthickgrad}]{\pflOx},{\mavaly}) node[pflnoeud,left,font={\useKV[GraphiqueTikzAxes]{Police}}] {\mavalfmty} ;
  }%
}

\NewDocumentCommand\GenererPolynomeLagrange{ O{polylagrange} m m }{% (merci jfb pour son aide !!!!!!!!!!) syntaxe particulière
  % #1 = argument optionnel, nom du polynôme complet polylagrange
  % #2 = liste séparée par virgules x_1, ..., x_N
  % #3 = liste séparée par virgules y_1, ..., y_N
  % -------------------------------
  % #2 et #3 peuvent être n'importe quoi dont l'expansion complète
  % donne le même nombre de termes séparés par des virgules.
  % De plus ils peuvent utiliser la syntaxe de xint.
  % -------------------------------
  \xintdeffloatvar tmp_List_X = [#2];%
  \xintdeffloatvar tmp_List_Y = [#3];%
  % récupérer la longueur
  \edef\tmpN{\xinteval{len(*tmp_List_X)}}%
  % assigner les entrées à des variables temporaires
  \xintdeffloatvar \xintiloop [1+1] tmp_x_\xintiloopindex
  \ifnum\xintiloopindex<\tmpN\space,\repeat=*tmp_List_X;%
  \xintdeffloatvar \xintiloop [1+1] tmp_y_\xintiloopindex
  \ifnum\xintiloopindex<\tmpN\space,\repeat=*tmp_List_Y;%
  % Définition de polynômes interpolateurs élémentaires
  % Attention lorsque l'on va définir le polynôme final
  % comme combinaison linéaire, les polynômes élémentaires
  % resteront présents par leurs symboles car ils auront
  % une indéterminée comme variable.
  % Il faut donc que leurs noms soient dans le même namespace
  % que le polynôme final.  C'est donc ici #1 le name space. (OK !)
  \xintFor* ##1 in {\xintSeq{1}{\tmpN}}\do{%
    \xintdeffloatfunc #1_##1(x) = 
    iter(1; (i==##1)?{omit}{@*(x - tmp_x_\xintiieval{i})}, i=1..\tmpN)/
    iter(1; (i==##1)?{omit}{@*(tmp_x_##1 - tmp_x_\xintiieval{i})}, i=1..\tmpN);%
    }%
  % Définition du polynôme somme des y_i * L_i(x) \xintdeffunc Lagrange(x)
  \xintdeffloatfunc #1(x) = add(tmp_y_\xinteval{i} * #1_\xinteval{i}(x), i=1..\tmpN);%
}
\NewCommandCopy\DefineLagrangeCurve\GenererPolynomeLagrange

\NewDocumentCommand\MarquerPtsLagrange{ s O{} D<>{\normalfont\normalsize} m m }{%
  %#4 & #5 = liste des points, comme pour générer
  \setsepchar{,}%
  \readlist*\lagrangepointsabs{#4}%
  \readlist*\lagrangepointsordo{#5}%
  \foreach \i in {1,...,\lagrangepointsabslen}{%
    \IfBooleanTF{#1}%
      {\MarquerPts*[#2]<#3>{({\lagrangepointsabs[\i]},{\lagrangepointsordo[\i]})}}%
      {\MarquerPts[#2]<#3>{({\lagrangepointsabs[\i]},{\lagrangepointsordo[\i]})}}%
  }%
}

%====FONCTIONS ET COURBES 'classique + interpo + spline + dérivée + primitive'
\defKV[GraphiqueTikzCourbe]{%
  Pas=\def\pflstepcurve{#1},%
  Nom=\def\pflnamecurve{#1},%
  StyleTrace=\def\pflstylecurve{#1},%
  h=\def\pflhderiv{#1},%
  ValeursInterdites=\def\pflvalsinterdites{#1},%
  Sens=\def\pflsensparab{#1}
}
\setKVdefault[GraphiqueTikzCourbe]{%
  Couleur=black,%
  Debut={\pflxmin},%
  Fin={\pflxmax},%
  Pas={},%
  Clip=true,%
  Nom={},%
  Trace=false,%
  Tension=0.5,%
  StyleTrace={},%
  RestreindreY=false,%
  Restreindre=false,%
  h={},%
  Spline=false,%
  ValeursInterdites={},%
  Sens=V
}

\NewDocumentCommand\DefinirFonction{ O{} D<>{f} m }{%old version
  \restoreKV[GraphiqueTikzCourbe]%
  \setKV[GraphiqueTikzCourbe]{#1}%
  \xintdeffloatfunc #2(x) := #3 ;
  \IfStrEq{\pflstepcurve}{}%
  {%
    \IfStrEq{\pflvalsinterdites}{}%
      {%
        \xdef\pflstepcurve{\xintfloateval{((\useKV[GraphiqueTikzCourbe]{Fin})-(\useKV[GraphiqueTikzCourbe]{Debut}))/100}}%
      }%
      {%
        \xdef\pflstepcurve{\xintfloateval{((\useKV[GraphiqueTikzCourbe]{Fin})-(\useKV[GraphiqueTikzCourbe]{Debut}))/250}}%
      }%
  }%
  {}%
  \ifboolKV[GraphiqueTikzCourbe]{Clip}{\begin{scope}\clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax});}{}
  %suite
  \ifboolKV[GraphiqueTikzCourbe]{Trace}%
  {%
    \path[draw,pflcourbe,\pflstylecurve,{\useKV[GraphiqueTikzCourbe]{Couleur}},name path global=\pflnamecurve]
    plot[smooth] coordinates {%
      \xintthecoords\xintfloatexpr seq((x,#2(x)),x={\useKV[GraphiqueTikzCourbe]{Debut}}..[\pflstepcurve]..{\useKV[GraphiqueTikzCourbe]{Fin}},{\useKV[GraphiqueTikzCourbe]{Fin}})
      \relax}
    ;
  }%
  {%
    \path[draw=none,pflcourbe,{\useKV[GraphiqueTikzCourbe]{Couleur}},name path global=\pflnamecurve] plot[smooth] coordinates {%
    \xintthecoords\xintfloatexpr
    seq((x,#2(x)),x={\useKV[GraphiqueTikzCourbe]{Debut}}..[\pflstepcurve]..{\useKV[GraphiqueTikzCourbe]{Fin}},{\useKV[GraphiqueTikzCourbe]{Fin}})
    \relax
    };
  }%
  \ifboolKV[GraphiqueTikzCourbe]{Clip}{\end{scope}}{}
  }

\NewDocumentCommand\DefinirCourbe{ O{} D<>{f} m }{%
  \restoreKV[GraphiqueTikzCourbe]%
  \setKV[GraphiqueTikzCourbe]{#1}%
  \xintdeffloatfunc #2(x) := #3 ;
  %test dimension too large
  \xdef\pfloffsetV{\xintfloateval{((\pflymax)-(\pflymin))/20}}%
  \xdef\pflMinoffsetV{\xintfloateval{(\pflymin)-(\pfloffsetV)}}%
  \xdef\pflMaxoffsetV{\xintfloateval{(\pflymax)+(\pfloffsetV)}}%
  %bifurcation BI/noVI
  \IfStrEq{\pflvalsinterdites}{}%
    {%si pas de VI, code direct
      \xdef\pflstepcurve{\xintfloateval{((\useKV[GraphiqueTikzCourbe]{Fin})-(\useKV[GraphiqueTikzCourbe]{Debut}))/100}}%
      \ifboolKV[GraphiqueTikzCourbe]{Clip}{\begin{scope}\clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax});}{}
      \ifboolKV[GraphiqueTikzCourbe]{Trace}%
      {%
        \ifboolKV[GraphiqueTikzCourbe]{RestreindreY}%
        {%
          \path[draw,pflcourbe,\pflstylecurve,{\useKV[GraphiqueTikzCourbe]{Couleur}},name path global=\pflnamecurve] 
            plot[smooth] coordinates {%
            \xintthecoords\xintfloatexpr
            seq((x,min(max(#2(x),\pflMinoffsetV),\pflMaxoffsetV)),x={\useKV[GraphiqueTikzCourbe]{Debut}}..[\pflstepcurve]..{\useKV[GraphiqueTikzCourbe]{Fin}},{\useKV[GraphiqueTikzCourbe]{Fin}})
            \relax
          };
        }%
        {%
          \path[draw,pflcourbe,\pflstylecurve,{\useKV[GraphiqueTikzCourbe]{Couleur}},name path global=\pflnamecurve]
            plot[smooth] coordinates {%
            \xintthecoords\xintfloatexpr
            seq((x,#2(x)),x={\useKV[GraphiqueTikzCourbe]{Debut}}..[\pflstepcurve]..{\useKV[GraphiqueTikzCourbe]{Fin}},{\useKV[GraphiqueTikzCourbe]{Fin}})
            \relax
          };
        }%
      }%
      {%
        \ifboolKV[GraphiqueTikzCourbe]{RestreindreY}%
        {%
          \path[draw=none,pflcourbe,\pflstylecurve,{\useKV[GraphiqueTikzCourbe]{Couleur}},name path global=\pflnamecurve]
            plot[smooth] coordinates {%
            \xintthecoords\xintfloatexpr
            seq((x,min(max(#2(x),\pflMinoffsetV),\pflMaxoffsetV)),x={\useKV[GraphiqueTikzCourbe]{Debut}}..[\pflstepcurve]..{\useKV[GraphiqueTikzCourbe]{Fin}},{\useKV[GraphiqueTikzCourbe]{Fin}})
            \relax
          };
        }%
        {%
          \path[draw=none,pflcourbe,\pflstylecurve,{\useKV[GraphiqueTikzCourbe]{Couleur}},name path global=\pflnamecurve]
            plot[smooth] coordinates {%
            \xintthecoords\xintfloatexpr
            seq((x,#2(x)),x={\useKV[GraphiqueTikzCourbe]{Debut}}..[\pflstepcurve]..{\useKV[GraphiqueTikzCourbe]{Fin}},{\useKV[GraphiqueTikzCourbe]{Fin}})
            \relax
          };
        }%
      }%
      \ifboolKV[GraphiqueTikzCourbe]{Clip}{\end{scope}}{}
    }%
    {%sinon, VI, code spécifique
      \xdef\pflstepcurve{\xintfloateval{((\useKV[GraphiqueTikzCourbe]{Fin})-(\useKV[GraphiqueTikzCourbe]{Debut}))/250}}%
      %génération des branches, si VI
      \xdef\pfllistebornes{\useKV[GraphiqueTikzCourbe]{Debut}}%
      \foreach \i in \pflvalsinterdites {%
        \xdef\pfllistebornes{\pfllistebornes,\xintfloateval{\i-(\pflstepcurve)},\xintfloateval{\i+(\pflstepcurve)}}%
      }%
      \xdef\pfllistebornes{\pfllistebornes,\useKV[GraphiqueTikzCourbe]{Fin}}%
      \setsepchar{,}%
      \readlist*\tkzintlistebornes{\pfllistebornes}%
      \xdef\tkzgrphnbbranches{\fpeval{\tkzintlisteborneslen/2}}%
      %suite
      \ifboolKV[GraphiqueTikzCourbe]{Clip}{\begin{scope}\clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax});}{}
      \ifboolKV[GraphiqueTikzCourbe]{Trace}%
        {%
          \path[draw,pflcourbe,\pflstylecurve,{\useKV[GraphiqueTikzCourbe]{Couleur}},name path global=\pflnamecurve] 
            \foreach \ib [evaluate=\ib as \ibdeb using {int(2*\ib-1)},evaluate=\ib as \ibfin using {int(2*\ib)}] in {1,...,\tkzgrphnbbranches}{%
              plot[smooth] coordinates {%
                \xintthecoords\xintfloatexpr seq((x,min(max(#2(x),\pflMinoffsetV),\pflMaxoffsetV)), x={\tkzintlistebornes[\ibdeb]}..[\pflstepcurve]..{\tkzintlistebornes[\ibfin]},{\tkzintlistebornes[\ibfin]}) \relax}
             } ;%
        }%
        {%
          \path[draw=none,pflcourbe,\pflstylecurve,{\useKV[GraphiqueTikzCourbe]{Couleur}},name path global=\pflnamecurve]
            \foreach \ib [evaluate=\ib as \ibdeb using {int(2*\ib-1)},evaluate=\ib as \ibfin using {int(2*\ib)}] in {1,...,\tkzgrphnbbranches}{%
              plot[smooth] coordinates {%
                \xintthecoords\xintfloatexpr seq((x,min(max(#2(x),\pflMinoffsetV),\pflMaxoffsetV)), x={\tkzintlistebornes[\ibdeb]}..[\pflstepcurve]..{\tkzintlistebornes[\ibfin]},{\tkzintlistebornes[\ibfin]}) \relax}
             } ;
        }%
        \ifboolKV[GraphiqueTikzCourbe]{Clip}{\end{scope}}{}
    }%
}

\NewDocumentCommand\TracerCourbe{ O{} D<>{} m }{%
  \restoreKV[GraphiqueTikzCourbe]%
  \setKV[GraphiqueTikzCourbe]{#1}%
  %test dimension too large
  \xdef\pfloffsetV{\xintfloateval{((\pflymax)-(\pflymin))/20}}%
  \xdef\pflMinoffsetV{\xintfloateval{(\pflymin)-(\pfloffsetV)}}%
  \xdef\pflMaxoffsetV{\xintfloateval{(\pflymax)+(\pfloffsetV)}}%
  %bifurcation BI/noVI
  \IfStrEq{\pflvalsinterdites}{}%
    {%si pas de VI, code direct
      \xdef\pflstepcurve{\xintfloateval{((\useKV[GraphiqueTikzCourbe]{Fin})-(\useKV[GraphiqueTikzCourbe]{Debut}))/100}}%
      \ifboolKV[GraphiqueTikzCourbe]{Clip}{\begin{scope}\clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax});}{}
      \IfStrEq{\pflnamecurve}{}%
        {%
          \ifboolKV[GraphiqueTikzCourbe]{RestreindreY}%
            {%
              \draw[pflcourbe,\pflstylecurve,{\useKV[GraphiqueTikzCourbe]{Couleur}}] 
                plot[smooth] coordinates {%
                \xintthecoords\xintfloatexpr
                seq((x,min(max(#3,\pflMinoffsetV),\pflMaxoffsetV)),x={\useKV[GraphiqueTikzCourbe]{Debut}}..[\pflstepcurve]..{\useKV[GraphiqueTikzCourbe]{Fin}},{\useKV[GraphiqueTikzCourbe]{Fin}})
                \relax
              };
            }%
            {%
              \draw[pflcourbe,\pflstylecurve,{\useKV[GraphiqueTikzCourbe]{Couleur}}] 
                plot[smooth] coordinates {%
                \xintthecoords\xintfloatexpr
                seq((x,#3),x={\useKV[GraphiqueTikzCourbe]{Debut}}..[\pflstepcurve]..{\useKV[GraphiqueTikzCourbe]{Fin}},{\useKV[GraphiqueTikzCourbe]{Fin}})
                \relax
              };
            }%
        }%
        {%
          \ifboolKV[GraphiqueTikzCourbe]{RestreindreY}%
            {%
              \draw[pflcourbe,\pflstylecurve,{\useKV[GraphiqueTikzCourbe]{Couleur}},name path global=\pflnamecurve] 
                plot[smooth] coordinates {%
                \xintthecoords\xintfloatexpr
                seq((x,min(max(#3,\pflMinoffsetV),\pflMaxoffsetV)),x={\useKV[GraphiqueTikzCourbe]{Debut}}..[\pflstepcurve]..{\useKV[GraphiqueTikzCourbe]{Fin}},{\useKV[GraphiqueTikzCourbe]{Fin}})
                \relax
              };
            }%
            {%
              \draw[pflcourbe,\pflstylecurve,{\useKV[GraphiqueTikzCourbe]{Couleur}},name path global=\pflnamecurve] 
                plot[smooth] coordinates {%
                \xintthecoords\xintfloatexpr
                seq((x,#3),x={\useKV[GraphiqueTikzCourbe]{Debut}}..[\pflstepcurve]..{\useKV[GraphiqueTikzCourbe]{Fin}},{\useKV[GraphiqueTikzCourbe]{Fin}})
                \relax
              };
            }%
        }%
      \ifboolKV[GraphiqueTikzCourbe]{Clip}{\end{scope}}{}
    }%
    {%sinon, VI, code spécifique
      \xdef\pflstepcurve{\xintfloateval{((\useKV[GraphiqueTikzCourbe]{Fin})-(\useKV[GraphiqueTikzCourbe]{Debut}))/250}}%
      %génération des branches, si VI
      \xdef\pfllistebornes{\useKV[GraphiqueTikzCourbe]{Debut}}%
      \foreach \i in \pflvalsinterdites {%
        \xdef\pfllistebornes{\pfllistebornes,\xintfloateval{\i-(\pflstepcurve)},\xintfloateval{\i+(\pflstepcurve)}}%
      }%
      \xdef\pfllistebornes{\pfllistebornes,\useKV[GraphiqueTikzCourbe]{Fin}}%
      \setsepchar{,}%
      \readlist*\tkzintlistebornes{\pfllistebornes}%
      %\typeout{=== \pfllistebornes ===}
      \xdef\tkzgrphnbbranches{\fpeval{\tkzintlisteborneslen/2}}%
      \ifboolKV[GraphiqueTikzCourbe]{Clip}{\begin{scope}\clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax});}{}
      \IfStrEq{\pflnamecurve}{}%
        {%
          \draw[pflcourbe,\pflstylecurve,{\useKV[GraphiqueTikzCourbe]{Couleur}}] 
            \foreach \ib [evaluate=\ib as \ibdeb using {int(2*\ib-1)},evaluate=\ib as \ibfin using {int(2*\ib)}] in {1,...,\tkzgrphnbbranches}{%
              plot[smooth] coordinates {%
                \xintthecoords\xintfloatexpr seq((x,min(max(#3,\pflMinoffsetV),\pflMaxoffsetV)), x={\tkzintlistebornes[\ibdeb]}..[\pflstepcurve]..{\tkzintlistebornes[\ibfin]},{\tkzintlistebornes[\ibfin]}) \relax}
            } ;%
        }%
        {%
          \draw[pflcourbe,\pflstylecurve,{\useKV[GraphiqueTikzCourbe]{Couleur}},name path global=\pflnamecurve] 
            \foreach \ib [evaluate=\ib as \ibdeb using {int(2*\ib-1)},evaluate=\ib as \ibfin using {int(2*\ib)}] in {1,...,\tkzgrphnbbranches}{%
              plot[smooth] coordinates {%
                \xintthecoords\xintfloatexpr seq((x,min(max(#3,\pflMinoffsetV),\pflMaxoffsetV)), x={\tkzintlistebornes[\ibdeb]}..[\pflstepcurve]..{\tkzintlistebornes[\ibfin]},{\tkzintlistebornes[\ibfin]}) \relax}
            } ;%
        }%
      \ifboolKV[GraphiqueTikzCourbe]{Clip}{\end{scope}}{}
    }%
}

\defKV[GraphiqueVoisinageTikz]{%
  Couleurs=\def\tkzgraphcoulvoisin{#1},%
  CouleurAsymptote=\def\tkzgraphcoulasymptvoisin{#1},%
  Opacite=\def\tkzgraphopacvoisin{#1},%
  Entree=\def\tkzgraphentreevoisin{#1},%
  LimiteEn=\def\tkzgraphvalavoisin{#1},%
  TypeLimite=\def\tkzgraphtypevoisin{#1},%
  DebutX=\def\tkzgraphxinitvoisin{#1},%
  FinX=\def\tkzgraphxfinvoisin{#1}
}

\setKVdefault[GraphiqueVoisinageTikz]{%
  Couleurs=blue,%
  CouleurAsymptote=orange,%
  Opacite=0.15,
  Entree=auto,%
  LimiteEn=0,%
  TypeLimite={L en +inf},%
  Asymptote=true,%
  Fleches=true,%
  DebutX=\pflxmin,%
  FinX=\pflxmax
}

\NewDocumentCommand\AfficherVoisinage{ O{} D<>{cf} m m }{%
  %#1 = Clés
  %#2 = nom de la courbe
  %#3 = limite/seuil
  %#4 = epsilon si besoin
  \restoreKV[GraphiqueVoisinageTikz]%
  \setKV[GraphiqueVoisinageTikz]{#1}%
  \IfStrEqCase{\tkzgraphtypevoisin}{%
    %------------------------
    %limite finie en +infini%
    {L en +inf}%
    {%
      \IfStrEq{\tkzgraphentreevoisin}{auto}%
      {%
        % path tube-haut : y = L+epsilon (droite horizontale)
        % path tube-bas  : y = L-epsilon (droite horizontale)
        \path[pfltraitvoisinage,name path global=pfltubeH] ({\tkzgraphxinitvoisin},{#3+(#4)}) -- ({\pflxmax},{#3+(#4)}) ;
        \path[pfltraitvoisinage,name path global=pfltubeB] ({\tkzgraphxinitvoisin},{#3-(#4)}) -- ({\pflxmax},{#3-(#4)}) ;
        % intersections avec la courbe
        \path[name intersections={of=#2 and pfltubeH,name=pflintH, total=\t}] \pgfextra{\xdef\tmpintHtot{\t}};
        \path[name intersections={of=#2 and pfltubeB,name=pflintB, total=\t}] \pgfextra{\xdef\tmpintBtot{\t}};
        % récupération des dernières abscisses%
        % Cas possibles
        \xintifboolexpr{\tmpintHtot > 0 'and' \tmpintBtot > 0}%
        {% intersection des deux côtés → max des deux dernières abscisses
          \path (pflintH-\tmpintHtot) ;
          \pgfgetlastxy{\macrox}{\macroy}%
          \xdef\pflxentreeH{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
          \path (pflintB-\tmpintBtot) ;
          \pgfgetlastxy{\macrox}{\macroy}%
          \xdef\pflxentreeB{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
          \xdef\tmpvoisinageentreeX{\xintfloateval{max(\pflxentreeH,\pflxentreeB)}}%
        }%
        {\xintifboolexpr{\tmpintHtot > 0}%
          {% uniquement par le haut
            \path (pflintH-\tmpintHtot) ;
            \pgfgetlastxy{\macrox}{\macroy}%
            \xdef\tmpvoisinageentreeX{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
          }%
          {\xintifboolexpr{\tmpintBtot > 0}%
            {% uniquement par le bas
              \path (pflintB-\tmpintBtot) ;
              \pgfgetlastxy{\macrox}{\macroy}%
              \xdef\tmpvoisinageentreeX{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
            }%
            {% aucune intersection → courbe entièrement dans le tube
              \xdef\tmpvoisinageentreeX{\pflxmin}%
            }%
          }%
        }%
      }%
      {%
        \xdef\tmpvoisinageentreeX{\tkzgraphentreevoisin}%
      }%
      \ifboolKV[GraphiqueVoisinageTikz]{Asymptote}%
        {%
           \draw[pfltraitvoisinage,\tkzgraphcoulasymptvoisin] ({\pflxmin},{(#3)}) -- (\pflxmax,{(#3)}) ;
        }%
        {}%
      \fill[opacity=\tkzgraphopacvoisin,\tkzgraphcoulvoisin] (\tmpvoisinageentreeX,{(#3)-(#4)}) rectangle ({\pflxmax},{(#3)+(#4)}) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({\pflxmin},{(#3)-(#4)}) -- (\pflxmax,{(#3)-(#4)}) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({\pflxmin},{(#3)+(#4)}) -- (\pflxmax,{(#3)+(#4)}) ;
      \draw[pfltraitvoisinage,densely dashed,\tkzgraphcoulvoisin] ({\tmpvoisinageentreeX},{#3-(#4)}) -- ({\tmpvoisinageentreeX},{#3+(#4)}) ;
    \ifboolKV[GraphiqueVoisinageTikz]{Fleches}%
    {%
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin,pflflecheg] ({\tmpvoisinageentreeX},{#3+(#4)}) --++ (0,3mm) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin,pflflecheg] ({\tmpvoisinageentreeX},{#3-(#4)}) --++ (0,-3mm) ;
    }%
    {%
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({\tmpvoisinageentreeX},{#3+(#4)}) --++ (0,3mm) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({\tmpvoisinageentreeX},{#3-(#4)}) --++ (0,-3mm) ;
    }%
    }%
    %------------------------
    %limite finie en -infini%
    {L en -inf}%
    {%
      \IfStrEq{\tkzgraphentreevoisin}{auto}%
      {%
        % path tube-haut : y = L+epsilon (droite horizontale)
        % path tube-bas  : y = L-epsilon (droite horizontale)
        \path[pfltraitvoisinage,name path global=pfltubeH] ({\pflxmin},{#3+(#4)}) -- ({\tkzgraphxfinvoisin},{#3+(#4)}) ;
        \path[pfltraitvoisinage,name path global=pfltubeB] ({\pflxmin},{#3-(#4)}) -- ({\tkzgraphxfinvoisin},{#3-(#4)}) ;
        % intersections avec la courbe
        \path[name intersections={of=#2 and pfltubeH,name=pflintH, total=\t}] \pgfextra{\xdef\tmpintHtot{\t}};
        \path[name intersections={of=#2 and pfltubeB,name=pflintB, total=\t}] \pgfextra{\xdef\tmpintBtot{\t}};
        % récupération des dernières abscisses%
        % Cas possibles
        \xintifboolexpr{\tmpintHtot > 0 'and' \tmpintBtot > 0}%
        {% intersection des deux côtés → max des deux dernières abscisses
          \path (pflintH-\tmpintHtot) ;
          \pgfgetlastxy{\macrox}{\macroy}%
          \xdef\pflxentreeH{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
          \path (pflintB-\tmpintBtot) ;
          \pgfgetlastxy{\macrox}{\macroy}%
          \xdef\pflxentreeB{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
          \xdef\tmpvoisinageentreeX{\xintfloateval{max(\pflxentreeH,\pflxentreeB)}}%
        }%
        {\xintifboolexpr{\tmpintHtot > 0}%
          {% uniquement par le haut
            \path (pflintH-\tmpintHtot) ;
            \pgfgetlastxy{\macrox}{\macroy}%
            \xdef\tmpvoisinageentreeX{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
          }%
          {\xintifboolexpr{\tmpintBtot > 0}%
            {% uniquement par le bas
              \path (pflintB-\tmpintBtot) ;
              \pgfgetlastxy{\macrox}{\macroy}%
              \xdef\tmpvoisinageentreeX{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
            }%
            {% aucune intersection → courbe entièrement dans le tube
              \xdef\tmpvoisinageentreeX{\pflxmax}%
            }%
          }%
        }%
      }%
      {%
        \xdef\tmpvoisinageentreeX{\tkzgraphentreevoisin}%
      }%
    \ifboolKV[GraphiqueVoisinageTikz]{Asymptote}%
        {%
           \draw[pfltraitvoisinage,\tkzgraphcoulasymptvoisin] ({\pflxmin},{(#3)}) -- (\pflxmax,{(#3)}) ;
        }%
        {}%
      \fill[opacity=\tkzgraphopacvoisin,\tkzgraphcoulvoisin] (\tmpvoisinageentreeX,{(#3)-(#4)}) rectangle ({\pflxmin},{(#3)+(#4)}) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({\pflxmin},{(#3)-(#4)}) -- (\pflxmax,{(#3)-(#4)}) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({\pflxmin},{(#3)+(#4)}) -- (\pflxmax,{(#3)+(#4)}) ;
      \draw[pfltraitvoisinage,densely dashed,\tkzgraphcoulvoisin] ({\tmpvoisinageentreeX},{#3-(#4)}) -- ({\tmpvoisinageentreeX},{#3+(#4)}) ;
    \ifboolKV[GraphiqueVoisinageTikz]{Fleches}%
    {%
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin,pflflecheg] ({\tmpvoisinageentreeX},{#3+(#4)}) --++ (0,3mm) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin,pflflecheg] ({\tmpvoisinageentreeX},{#3-(#4)}) --++ (0,-3mm) ;
    }%
    {%
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({\tmpvoisinageentreeX},{#3+(#4)}) --++ (0,3mm) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({\tmpvoisinageentreeX},{#3-(#4)}) --++ (0,-3mm) ;
    }%
    }%
    %------------------------
    %limite infinie en +infini%
    {+inf en +inf}%
    {%
      \IfStrEq{\tkzgraphentreevoisin}{auto}%
      {%
        % path seuil : y = #3
        \path[pfltraitvoisinage,name path global=pflseuilvoisin] ({\tkzgraphxinitvoisin},{#3}) -- ({\pflxmax},{#3}) ;
        % intersections avec la courbe
        \path[name intersections={of=#2 and pflseuilvoisin,name=pflintS,total=\t}] \pgfextra{\xdef\tmpintStot{\t}};
        % Cas possibles
        \xintifboolexpr{\tmpintStot > 0}%
      {%
        \path (pflintS-\tmpintStot) ;
            \pgfgetlastxy{\macrox}{\macroy}%
            \xdef\tmpvoisinageentreeX{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
      }%
      {%
        \xdef\tmpvoisinageentreeX{\pflxmin}%
      }%
      }%
      {%
        \xdef\tmpvoisinageentreeX{\tkzgraphentreevoisin}%
      }%
      \fill[opacity=\tkzgraphopacvoisin,\tkzgraphcoulvoisin] (\tmpvoisinageentreeX,{(#3)}) rectangle ({\pflxmax},{\pflymax}) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({\pflxmin},{(#3)}) -- (\pflxmax,{(#3)}) ;
      \draw[pfltraitvoisinage,,densely dashed,\tkzgraphcoulvoisin] ({\tmpvoisinageentreeX},{(#3)}) -- (\tmpvoisinageentreeX,{\pflymax}) ;
    \ifboolKV[GraphiqueVoisinageTikz]{Fleches}%
    {%
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin,pflflecheg] ({\tmpvoisinageentreeX},{#3}) --++ (0,-3mm);
    }%
    {%
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({\tmpvoisinageentreeX},{#3}) --++ (0,-3mm);
    }%
    }%
    %limite -infinie en +infini%
    {-inf en +inf}%
    {%
      \IfStrEq{\tkzgraphentreevoisin}{auto}%
      {%
        % path seuil : y = #3
        \path[pfltraitvoisinage,name path global=pflseuilvoisin] ({\pflxmin},{#3}) -- ({\tkzgraphxfinvoisin},{#3}) ;
        % intersections avec la courbe
        \path[name intersections={of=#2 and pflseuilvoisin,name=pflintS,total=\t}] \pgfextra{\xdef\tmpintStot{\t}};
        % Cas possibles
        \xintifboolexpr{\tmpintStot > 0}%
      {%
        \path (pflintS-\tmpintStot) ;
            \pgfgetlastxy{\macrox}{\macroy}%
            \xdef\tmpvoisinageentreeX{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
      }%
      {%
        \xdef\tmpvoisinageentreeX{\pflxmax}%
      }%
      }%
      {%
        \xdef\tmpvoisinageentreeX{\tkzgraphentreevoisin}%
      }%
      \fill[opacity=\tkzgraphopacvoisin,\tkzgraphcoulvoisin] (\tmpvoisinageentreeX,{(#3)}) rectangle ({\pflxmax},{\pflymin}) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({\pflxmin},{(#3)}) -- (\pflxmax,{(#3)}) ;
    \draw[pfltraitvoisinage,,densely dashed,\tkzgraphcoulvoisin] ({\tmpvoisinageentreeX},{(#3)}) -- (\tmpvoisinageentreeX,{\pflymin}) ;
    \ifboolKV[GraphiqueVoisinageTikz]{Fleches}%
    {%
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin,pflflecheg] ({\tmpvoisinageentreeX},{#3}) --++ (0,3mm);
    }%
    {%
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({\tmpvoisinageentreeX},{#3}) --++ (0,3mm);
    }%
    }%
  %limite +infinie en -infini%
    {+inf en -inf}%
    {%
      \IfStrEq{\tkzgraphentreevoisin}{auto}%
      {%
        % path seuil : y = #3
        \path[pfltraitvoisinage,name path global=pflseuilvoisin] ({\pflxmin},{#3}) -- ({\tkzgraphxfinvoisin},{#3}) ;
        % intersections avec la courbe
        \path[name intersections={of=#2 and pflseuilvoisin,name=pflintS,total=\t}] \pgfextra{\xdef\tmpintStot{\t}};
        % Cas possibles
        \xintifboolexpr{\tmpintStot > 0}%
      {%
        \path (pflintS-\tmpintStot) ;
            \pgfgetlastxy{\macrox}{\macroy}%
            \xdef\tmpvoisinageentreeX{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
      }%
      {%
        \xdef\tmpvoisinageentreeX{\pflxmin}%
      }%
      }%
      {%
        \xdef\tmpvoisinageentreeX{\tkzgraphentreevoisin}%
      }%
      \fill[opacity=\tkzgraphopacvoisin,\tkzgraphcoulvoisin] (\tmpvoisinageentreeX,{(#3)}) rectangle ({\pflxmin},{\pflymax}) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({\pflxmin},{(#3)}) -- (\pflxmax,{(#3)}) ;
    \draw[pfltraitvoisinage,,densely dashed,\tkzgraphcoulvoisin] ({\tmpvoisinageentreeX},{(#3)}) -- (\tmpvoisinageentreeX,{\pflymax}) ;
      \ifboolKV[GraphiqueVoisinageTikz]{Fleches}%
    {%
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin,pflflecheg] ({\tmpvoisinageentreeX},{#3}) --++ (0,-3mm);
    }%
    {%
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({\tmpvoisinageentreeX},{#3}) --++ (0,-3mm);
    }%
    }%
  %limite +infinie en -infini%
    {-inf en -inf}%
    {%
      \IfStrEq{\tkzgraphentreevoisin}{auto}%
      {%
        % path seuil : y = #3
        \path[pfltraitvoisinage,name path global=pflseuilvoisin] ({\pflxmin},{#3}) -- ({\tkzgraphxfinvoisin},{#3}) ;
        % intersections avec la courbe
        \path[name intersections={of=#2 and pflseuilvoisin,name=pflintS,total=\t}] \pgfextra{\xdef\tmpintStot{\t}};
        % Cas possibles
        \xintifboolexpr{\tmpintStot > 0}%
      {%
        \path (pflintS-\tmpintStot) ;
            \pgfgetlastxy{\macrox}{\macroy}%
            \xdef\tmpvoisinageentreeX{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
      }%
      {%
        \xdef\tmpvoisinageentreeX{\pflxmax}%
      }%
      }%
      {%
        \xdef\tmpvoisinageentreeX{\tkzgraphentreevoisin}%
      }%
      \fill[opacity=\tkzgraphopacvoisin,\tkzgraphcoulvoisin] (\tmpvoisinageentreeX,{(#3)}) rectangle ({\pflxmin},{\pflymin}) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({\pflxmin},{(#3)}) -- (\pflxmax,{(#3)}) ;
    \draw[pfltraitvoisinage,,densely dashed,\tkzgraphcoulvoisin] ({\tmpvoisinageentreeX},{(#3)}) -- (\tmpvoisinageentreeX,{\pflymin}) ;
      \ifboolKV[GraphiqueVoisinageTikz]{Fleches}%
    {%
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin,pflflecheg] ({\tmpvoisinageentreeX},{#3}) --++ (0,3mm);
    }%
    {%
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({\tmpvoisinageentreeX},{#3}) --++ (0,3mm);
    }%
    }%
    %------------------------
    %limite infinie en a%
    {+inf en a}
    {%
      \IfStrEq{\tkzgraphentreevoisin}{auto}%
      {%
        % path tube-haut : x = L+epsilon (droite verticale)
        % path tube-bas  : x = L-epsilon (droite verticale)
        \path[pfltraitvoisinage,name path global=pfltubeG] ({#3-(#4)},{\pflymin}) -- ({#3-(#4)},{\pflymax}) ;
        \path[pfltraitvoisinage,name path global=pfltubeD] ({#3+(#4)},{\pflymin}) -- ({#3+(#4)},{\pflymax}) ;
        % intersections avec la courbe
        \path[name intersections={of=#2 and pfltubeG,name=pflintG, total=\t}] \pgfextra{\xdef\tmpintGtot{\t}};
        \path[name intersections={of=#2 and pfltubeD,name=pflintD, total=\t}] \pgfextra{\xdef\tmpintDtot{\t}};
        % récupération des dernières abscisses%
        % Cas possibles
        \xintifboolexpr{\tmpintGtot > 0 'and' \tmpintDtot > 0}%
        {% intersection des deux côtés → min des deux deltas...
          \path (pflintG-\tmpintGtot) ; 
          \pgfgetlastxy{\macrox}{\macroy}%
          \xdef\pflyentreeG{\xintfloateval{(\ConvertirPtToCm{\macroy})/(\pflyunit)}}%
          \path (pflintD-\tmpintDtot) ;
          \pgfgetlastxy{\macrox}{\macroy}%
          \xdef\pflyentreeD{\xintfloateval{(\ConvertirPtToCm{\macroy})/(\pflyunit)}}%
      \xdef\pflyentree{\xintfloateval{max(\pflyentreeG,\pflyentreeD)}}%
        }%
        {\xintifboolexpr{\tmpintDtot > 0}%
          {% uniquement par la droite
            \path (pflintD-\tmpintDtot) ;
            \pgfgetlastxy{\macrox}{\macroy}%
            \xdef\pflyentree{\xintfloateval{(\ConvertirPtToCm{\macroy})/(\pflyunit)}}%
          }%
          {\xintifboolexpr{\tmpintGtot > 0}%
            {% uniquement par le bas
              \path (pflintG-\tmpintGtot) ;
              \pgfgetlastxy{\macrox}{\macroy}%
              \xdef\pflyentree{\xintfloateval{(\ConvertirPtToCm{\macroy})/(\pflyunit)}}%
            }%
            {% aucune intersection → courbe entièrement dans le tube
              \xdef\pflyentree{\pflymin}%
            }%
          }%
        }%
      }%
      {%
        \xdef\pflyentree{\tkzgraphentreevoisin}%
      }%
    \ifboolKV[GraphiqueVoisinageTikz]{Asymptote}%
        {%
           \draw[pfltraitvoisinage,\tkzgraphcoulasymptvoisin] ({(#3)},{\pflymin}) -- ({(#3)},{\pflymax}) ;
        }%
        {}%
      \fill[opacity=\tkzgraphopacvoisin,\tkzgraphcoulvoisin] ({(#3)-(#4)},{\pflyentree}) rectangle ({(#3)+(#4)},{\pflymax}) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({(#3)-(#4)},{\pflymin}) -- ({(#3)-(#4)},{\pflymax}) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({(#3)+(#4)},{\pflymin}) -- ({(#3)+(#4)},{\pflymax}) ;
    \draw[pfltraitvoisinage,,densely dashed,\tkzgraphcoulvoisin] ({(#3)-(#4)},{\pflyentree}) -- ({(#3)+(#4)},{\pflyentree}) ;
      % \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({(#3)-(#4)},{\tmpvoisinageentreeY}) -- ({(#3)+(#4)},{\tmpvoisinageentreeY}) ;
    \ifboolKV[GraphiqueVoisinageTikz]{Fleches}%
    {%
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin,pflflecheg] ({#3-(#4)},{\pflyentree}) --++ (-3mm,0) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin,pflflecheg] ({#3+(#4)},{\pflyentree}) --++ (3mm,0) ;
    }%
    {%
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({#3-(#4)},{\pflyentree}) --++ (-3mm,0) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({#3+(#4)},{\pflyentree}) --++ (3mm,0) ;
    }%
    }%
  %------------------------
    %limite -infinie en a%
    {-inf en a}
    {%
      \IfStrEq{\tkzgraphentreevoisin}{auto}%
      {%
        % path tube-haut : x = L+epsilon (droite verticale)
        % path tube-bas  : x = L-epsilon (droite verticale)
        \path[pfltraitvoisinage,name path global=pfltubeG] ({#3-(#4)},{\pflymin}) -- ({#3-(#4)},{\pflymax}) ;
        \path[pfltraitvoisinage,name path global=pfltubeD] ({#3+(#4)},{\pflymin}) -- ({#3+(#4)},{\pflymax}) ;
        % intersections avec la courbe
        \path[name intersections={of=#2 and pfltubeG,name=pflintG, total=\t}] \pgfextra{\xdef\tmpintGtot{\t}};
        \path[name intersections={of=#2 and pfltubeD,name=pflintD, total=\t}] \pgfextra{\xdef\tmpintDtot{\t}};
        % récupération des dernières abscisses%
        % Cas possibles
        \xintifboolexpr{\tmpintGtot > 0 'and' \tmpintDtot > 0}%
        {% intersection des deux côtés
          \path (pflintG-\tmpintGtot) ; 
          \pgfgetlastxy{\macrox}{\macroy}%
          \xdef\pflyentreeG{\xintfloateval{(\ConvertirPtToCm{\macroy})/(\pflyunit)}}%
          \path (pflintD-\tmpintDtot) ;
          \pgfgetlastxy{\macrox}{\macroy}%
          \xdef\pflyentreeD{\xintfloateval{(\ConvertirPtToCm{\macroy})/(\pflyunit)}}%
      \xdef\pflyentree{\xintfloateval{min(\pflyentreeG,\pflyentreeD)}}%
        }%
        {\xintifboolexpr{\tmpintDtot > 0}%
          {% uniquement par la droite
            \path (pflintD-\tmpintDtot) ;
            \pgfgetlastxy{\macrox}{\macroy}%
            \xdef\pflyentree{\xintfloateval{(\ConvertirPtToCm{\macroy})/(\pflyunit)}}%
          }%
          {\xintifboolexpr{\tmpintGtot > 0}%
            {% uniquement par le bas
              \path (pflintG-\tmpintGtot) ;
              \pgfgetlastxy{\macrox}{\macroy}%
              \xdef\pflyentree{\xintfloateval{(\ConvertirPtToCm{\macroy})/(\pflyunit)}}%
            }%
            {% aucune intersection → courbe entièrement dans le tube
              \xdef\pflyentree{\pflymax}%
            }%
          }%
        }%
      }%
      {%
        \xdef\pflyentree{\tkzgraphentreevoisin}%
      }%
    \ifboolKV[GraphiqueVoisinageTikz]{Asymptote}%
        {%
           \draw[pfltraitvoisinage,\tkzgraphcoulasymptvoisin] ({(#3)},{\pflymin}) -- ({(#3)},{\pflymax}) ;
        }%
        {}%
      \fill[opacity=\tkzgraphopacvoisin,\tkzgraphcoulvoisin] ({(#3)-(#4)},{\pflyentree}) rectangle ({(#3)+(#4)},{\pflymin}) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({(#3)-(#4)},{\pflymin}) -- ({(#3)-(#4)},{\pflymax}) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({(#3)+(#4)},{\pflymin}) -- ({(#3)+(#4)},{\pflymax}) ;
    \draw[pfltraitvoisinage,,densely dashed,\tkzgraphcoulvoisin] ({(#3)-(#4)},{\pflyentree}) -- ({(#3)+(#4)},{\pflyentree}) ;
      % \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({(#3)-(#4)},{\tmpvoisinageentreeY}) -- ({(#3)+(#4)},{\tmpvoisinageentreeY}) ;
    \ifboolKV[GraphiqueVoisinageTikz]{Fleches}%
    {%
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin,pflflecheg] ({#3-(#4)},{\pflyentree}) --++ (-3mm,0) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin,pflflecheg] ({#3+(#4)},{\pflyentree}) --++ (3mm,0) ;
    }%
    {%
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({#3-(#4)},{\pflyentree}) --++ (-3mm,0) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({#3+(#4)},{\pflyentree}) --++ (3mm,0) ;
    }%
    }%
    %------------------------
    %limite infinie en Ld%
    {+inf en a+}%
    {%
      \IfStrEq{\tkzgraphentreevoisin}{auto}%
      {%
        % path tube-haut : x = L+epsilon (droite verticale)
        \path[pfltraitvoisinage,name path global=pfltubeD] ({#3+(#4)},{\pflymin}) -- ({#3+(#4)},{\pflymax}) ;
        % intersections avec la courbe
        \path[name intersections={of=#2 and pfltubeD,name=pflintD, total=\t}] \pgfextra{\xdef\tmpintDtot{\t}};
        % récupération des dernières abscisses%
        % Cas possibles
        \xintifboolexpr{\tmpintDtot > 0}%
        {% uniquement par le haut
          \path (pflintD-\tmpintDtot) ;
          \pgfgetlastxy{\macrox}{\macroy}%
          \xdef\tmpvoisinageentreeY{\xintfloateval{(\ConvertirPtToCm{\macroy})/(\pflyunit)}}%
        }%
        {% aucune intersection → courbe entièrement dans le tube
              \xdef\tmpvoisinageentreeY{\pflymin}%
        }%
      }%
      {%
        \xdef\tmpvoisinageentreeY{\tkzgraphentreevoisin}%
      }%
      \fill[opacity=\tkzgraphopacvoisin,\tkzgraphcoulvoisin] ({(#3)},{\tmpvoisinageentreeY}) rectangle ({(#3)+(#4)},{\pflymax}) ;
      \ifboolKV[GraphiqueVoisinageTikz]{Asymptote}%
        {%
           \draw[pfltraitvoisinage,\tkzgraphcoulasymptvoisin] ({(#3)},{\pflymin}) -- ({(#3)},{\pflymax}) ;
        }%
        {}%
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({(#3)+(#4)},{\pflymin}) -- ({(#3)+(#4)},{\pflymax}) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({(#3)},{\tmpvoisinageentreeY}) -- ({(#3)+(#4)},{\tmpvoisinageentreeY}) ;
    \ifboolKV[GraphiqueVoisinageTikz]{Fleches}%
    {%
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin,pflflecheg] ({#3},{\tmpvoisinageentreeY}) --++ (-3mm,0) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin,pflflecheg] ({#3+(#4)},{\tmpvoisinageentreeY}) --++ (3mm,0) ;
    }%
    {%
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin,pflflecheg] ({#3},{\tmpvoisinageentreeY}) --++ (-3mm,0) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin,pflflecheg] ({#3+(#4)},{\tmpvoisinageentreeY}) --++ (3mm,0) ;
    }%
    }%
  %------------------------
    %limite infinie en Lg%
    {+inf en a-}%
    {%
      \IfStrEq{\tkzgraphentreevoisin}{auto}%
      {%
        % path tube-haut : x = L+epsilon (droite verticale)
        \path[pfltraitvoisinage,name path global=pfltubeD] ({#3-(#4)},{\pflymin}) -- ({#3-(#4)},{\pflymax}) ;
        % intersections avec la courbe
        \path[name intersections={of=#2 and pfltubeD,name=pflintD, total=\t}] \pgfextra{\xdef\tmpintDtot{\t}};
        % récupération des dernières abscisses%
        % Cas possibles
        \xintifboolexpr{\tmpintDtot > 0}%
        {% uniquement par le haut
          \path (pflintD-\tmpintDtot) ;
          \pgfgetlastxy{\macrox}{\macroy}%
          \xdef\tmpvoisinageentreeY{\xintfloateval{(\ConvertirPtToCm{\macroy})/(\pflyunit)}}%
        }%
        {% aucune intersection → courbe entièrement dans le tube
              \xdef\tmpvoisinageentreeY{\pflymin}%
        }%
      }%
      {%
        \xdef\tmpvoisinageentreeY{\tkzgraphentreevoisin}%
      }%
      \fill[opacity=\tkzgraphopacvoisin,\tkzgraphcoulvoisin] ({(#3)},{\tmpvoisinageentreeY}) rectangle ({(#3)-(#4)},{\pflymax}) ;
      \ifboolKV[GraphiqueVoisinageTikz]{Asymptote}%
        {%
           \draw[pfltraitvoisinage,\tkzgraphcoulasymptvoisin] ({(#3)},{\pflymin}) -- ({(#3)},{\pflymax}) ;
        }%
        {}%
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({(#3)-(#4)},{\pflymin}) -- ({(#3)-(#4)},{\pflymax}) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({(#3)},{\tmpvoisinageentreeY}) -- ({(#3)-(#4)},{\tmpvoisinageentreeY}) ;
    \ifboolKV[GraphiqueVoisinageTikz]{Fleches}%
    {%
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin,pflflecheg] ({#3},{\tmpvoisinageentreeY}) --++ (3mm,0) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin,pflflecheg] ({#3-(#4)},{\tmpvoisinageentreeY}) --++ (-3mm,0) ;
    }%
    {%
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({#3},{\tmpvoisinageentreeY}) --++ (3mm,0) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({#3-(#4)},{\tmpvoisinageentreeY}) --++ (-3mm,0) ;

    }%
    }%
    %------------------------
    %limite -infinie en Lg%
    {-inf en a-}%
    {%
      \IfStrEq{\tkzgraphentreevoisin}{auto}%
      {%
        % path tube-haut : x = L+epsilon (droite verticale)
        \path[pfltraitvoisinage,name path global=pfltubeD] ({#3-(#4)},{\pflymin}) -- ({#3-(#4)},{\pflymax}) ;
        % intersections avec la courbe
        \path[name intersections={of=#2 and pfltubeD,name=pflintD, total=\t}] \pgfextra{\xdef\tmpintDtot{\t}};
        % récupération des dernières abscisses%
        % Cas possibles
        \xintifboolexpr{\tmpintDtot > 0}%
        {% uniquement par le haut
          \path (pflintD-\tmpintDtot) ;
          \pgfgetlastxy{\macrox}{\macroy}%
          \xdef\tmpvoisinageentreeY{\xintfloateval{(\ConvertirPtToCm{\macroy})/(\pflyunit)}}%
        }%
        {% aucune intersection → courbe entièrement dans le tube
              \xdef\tmpvoisinageentreeY{\pflymax}%
        }%
      }%
      {%
        \xdef\tmpvoisinageentreeY{\tkzgraphentreevoisin}%
      }%
      \fill[opacity=\tkzgraphopacvoisin,\tkzgraphcoulvoisin] ({(#3)},{\tmpvoisinageentreeY}) rectangle ({(#3)-(#4)},{\pflymin}) ;
      \ifboolKV[GraphiqueVoisinageTikz]{Asymptote}%
        {%
           \draw[pfltraitvoisinage,\tkzgraphcoulasymptvoisin] ({(#3)},{\pflymin}) -- ({(#3)},{\pflymax}) ;
        }%
        {}%
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({(#3)-(#4)},{\pflymin}) -- ({(#3)-(#4)},{\pflymax}) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({(#3)},{\tmpvoisinageentreeY}) -- ({(#3)-(#4)},{\tmpvoisinageentreeY}) ;
    \ifboolKV[GraphiqueVoisinageTikz]{Fleches}%
    {%
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin,pflflecheg] ({#3},{\tmpvoisinageentreeY}) --++ (3mm,0) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin,pflflecheg] ({#3-(#4)},{\tmpvoisinageentreeY}) --++ (-3mm,0) ;
    }%
    {%
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({#3},{\tmpvoisinageentreeY}) --++ (3mm,0) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({#3-(#4)},{\tmpvoisinageentreeY}) --++ (-3mm,0) ;
    }%
      
    
    }%
  %------------------------
    %limite -infinie en Ld%
    {-inf en a+}%
    {%
      \IfStrEq{\tkzgraphentreevoisin}{auto}%
      {%
        % path tube-haut : x = L+epsilon (droite verticale)
        \path[pfltraitvoisinage,name path global=pfltubeD] ({#3+(#4)},{\pflymin}) -- ({#3+(#4)},{\pflymax}) ;
        % intersections avec la courbe
        \path[name intersections={of=#2 and pfltubeD,name=pflintD, total=\t}] \pgfextra{\xdef\tmpintDtot{\t}};
        % récupération des dernières abscisses%
        % Cas possibles
        \xintifboolexpr{\tmpintDtot > 0}%
        {% uniquement par le haut
          \path (pflintD-\tmpintDtot) ;
          \pgfgetlastxy{\macrox}{\macroy}%
          \xdef\tmpvoisinageentreeY{\xintfloateval{(\ConvertirPtToCm{\macroy})/(\pflyunit)}}%
        }%
        {% aucune intersection → courbe entièrement dans le tube
              \xdef\tmpvoisinageentreeY{\pflymax}%
        }%
      }%
      {%
        \xdef\tmpvoisinageentreeY{\tkzgraphentreevoisin}%
      }%
      \fill[opacity=\tkzgraphopacvoisin,\tkzgraphcoulvoisin] ({(#3)},{\tmpvoisinageentreeY}) rectangle ({(#3)+(#4)},{\pflymin}) ;
      \ifboolKV[GraphiqueVoisinageTikz]{Asymptote}%
        {%
           \draw[pfltraitvoisinage,\tkzgraphcoulasymptvoisin] ({(#3)},{\pflymin}) -- ({(#3)},{\pflymax}) ;
        }%
        {}%
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({(#3)+(#4)},{\pflymin}) -- ({(#3)+(#4)},{\pflymax}) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({(#3)},{\tmpvoisinageentreeY}) -- ({(#3)+(#4)},{\tmpvoisinageentreeY}) ;
    \ifboolKV[GraphiqueVoisinageTikz]{Fleches}%
    {%
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin,pflflecheg] ({#3},{\tmpvoisinageentreeY}) --++ (-3mm,0) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin,pflflecheg] ({#3+(#4)},{\tmpvoisinageentreeY}) --++ (3mm,0) ;
    }%
    {%
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({#3},{\tmpvoisinageentreeY}) --++ (-3mm,0) ;
      \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({#3+(#4)},{\tmpvoisinageentreeY}) --++ (3mm,0) ;
    }%
    }%
  %------------------------
    %continuité
    {L en a}%
    {%
      \IfStrEq{\tkzgraphentreevoisin}{auto}%
      {%
      %partie droite path tube-haut-bas : x = L+-epsilon (droites verticales)
        \path[pfltraitvoisinage,name path global=pfltubeDH] ({\tkzgraphvalavoisin},{#3+(#4)}) -- ({\pflxmax},{#3+(#4)}) ;
    \path[pfltraitvoisinage,name path global=pfltubeDB] ({\tkzgraphvalavoisin},{#3-(#4)}) -- ({\pflxmax},{#3-(#4)}) ;
        \path[name intersections={of=#2 and pfltubeDH,name=pflintDH, total=\t}] \pgfextra{\xdef\tmpintDHtot{\t}};
    \path[name intersections={of=#2 and pfltubeDB,name=pflintDB, total=\t}] \pgfextra{\xdef\tmpintDBtot{\t}};
        \xintifboolexpr{\tmpintDHtot > 0 'and' \tmpintDBtot > 0}%
      {%
        \path (pflintDH-1) ;
        \pgfgetlastxy{\macrox}{\macroy}%
        \xdef\pflxentreeDH{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
        \path (pflintDB-1) ;
        \pgfgetlastxy{\macrox}{\macroy}%
        \xdef\pflxentreeDB{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
        \xdef\pflvoisindeltaD{\xintfloateval{min(\pflxentreeDH,\pflxentreeDB)-\tkzgraphvalavoisin}}%
      }%
      {%
        \xintifboolexpr{\tmpintDHtot > 0}%
          {%
            \path (pflintDH-1) ;
            \pgfgetlastxy{\macrox}{\macroy}%
            \xdef\pflvoisindeltaD{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)-\tkzgraphvalavoisin}}%
          }%
          {%
            \xintifboolexpr{\tmpintDBtot > 0}%
              {%
                \path (pflintDB-1) ;
                \pgfgetlastxy{\macrox}{\macroy}%
                \xdef\pflvoisindeltaD{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)-\tkzgraphvalavoisin}}%
              }%
              {% aucune intersection → courbe dans le tube sur toute la partie droite
                \xdef\pflvoisindeltaD{\xintfloateval{\pflxmax-\tkzgraphvalavoisin}}%
              }%
          }%
      }%
      % partie gauche — paths de pflxmin à a
      \path[pfltraitvoisinage,name path global=pfltubeGH] ({\pflxmin},{#3+(#4)}) -- ({\tkzgraphvalavoisin},{#3+(#4)}) ;
      \path[pfltraitvoisinage,name path global=pfltubeGB] ({\pflxmin},{#3-(#4)}) -- ({\tkzgraphvalavoisin},{#3-(#4)}) ;
      \path[name intersections={of=#2 and pfltubeGH,name=pflintGH, total=\t}] \pgfextra{\xdef\tmpintGHtot{\t}};
      \path[name intersections={of=#2 and pfltubeGB,name=pflintGB, total=\t}] \pgfextra{\xdef\tmpintGBtot{\t}};
      % récupération du delta gauche
      \xintifboolexpr{\tmpintGHtot > 0 'and' \tmpintGBtot > 0}%
        {%
          \path (pflintGH-\tmpintGHtot) ;
          \pgfgetlastxy{\macrox}{\macroy}%
          \xdef\pflxentreeGH{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
          \path (pflintGB-\tmpintGBtot) ;
          \pgfgetlastxy{\macrox}{\macroy}%
          \xdef\pflxentreeGB{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
          \xdef\pflvoisindeltaG{\xintfloateval{\tkzgraphvalavoisin-max(\pflxentreeGH,\pflxentreeGB)}}%
        }%
        {%
          \xintifboolexpr{\tmpintGHtot > 0}%
            {%
              \path (pflintGH-\tmpintGHtot) ;
              \pgfgetlastxy{\macrox}{\macroy}%
              \xdef\pflvoisindeltaG{\xintfloateval{\tkzgraphvalavoisin-(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
            }%
            {%
              \xintifboolexpr{\tmpintGBtot > 0}%
                {%
                  \path (pflintGB-\tmpintGBtot) ;
                  \pgfgetlastxy{\macrox}{\macroy}%
                  \xdef\pflvoisindeltaG{\xintfloateval{\tkzgraphvalavoisin-(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
                }%
                {% aucune intersection
                  \xdef\pflvoisindeltaG{\xintfloateval{\tkzgraphvalavoisin-\pflxmin}}%
                }%
            }%
        }%
      % delta final
      \xdef\pflvoisindelta{\xintfloateval{min(\pflvoisindeltaD,\pflvoisindeltaG)}}%
    }%
    {%
      \xdef\pflvoisindelta{\tkzgraphentreevoisin}%
    }%
    % tube horizontal restreint à ]a-delta, a+delta[
    \fill[opacity=\tkzgraphopacvoisin,\tkzgraphcoulvoisin] 
      ({\xintfloateval{\tkzgraphvalavoisin-\pflvoisindelta}},{#3-(#4)}) 
      rectangle 
      ({\xintfloateval{\tkzgraphvalavoisin+\pflvoisindelta}},{#3+(#4)}) ;
    % bords horizontaux
    \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] 
      ({\pflxmin},{#3-(#4)}) -- ({\pflxmax},{#3-(#4)}) ;
    \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] 
      ({\pflxmin},{#3+(#4)}) -- ({\pflxmax},{#3+(#4)}) ;
    \draw[pfltraitvoisinage,,densely dashed,\tkzgraphcoulvoisin] ({\tkzgraphvalavoisin-\pflvoisindelta},{#3-(#4)}) -- ({\tkzgraphvalavoisin-\pflvoisindelta},{#3+(#4)}) ;
    \draw[pfltraitvoisinage,,densely dashed,\tkzgraphcoulvoisin] ({\tkzgraphvalavoisin+\pflvoisindelta},{#3-(#4)}) -- ({\tkzgraphvalavoisin+\pflvoisindelta},{#3+(#4)}) ;
    \ifboolKV[GraphiqueVoisinageTikz]{Asymptote}%
      {%
         \draw[pfltraitvoisinageasympt,\tkzgraphcoulasymptvoisin] ({(\tkzgraphvalavoisin)},{\pflymin}) -- ({(\tkzgraphvalavoisin)},{\pflymax}) ;
         \draw[pfltraitvoisinageasympt,\tkzgraphcoulasymptvoisin] ({\pflxmin},{#3}) -- ({\pflxmax},{#3}) ;
         
      }%
      {}%
    \ifboolKV[GraphiqueVoisinageTikz]{Fleches}%
      {%
        \draw[pfltraitvoisinage,\tkzgraphcoulvoisin,pflflecheg] ({\tkzgraphvalavoisin-\pflvoisindelta},{#3-(#4)}) --++ (0,-3mm) ;
        \draw[pfltraitvoisinage,\tkzgraphcoulvoisin,pflflecheg] ({\tkzgraphvalavoisin-\pflvoisindelta},{#3+(#4)}) --++ (0,3mm) ;
        \draw[pfltraitvoisinage,\tkzgraphcoulvoisin,pflflecheg] ({\tkzgraphvalavoisin+\pflvoisindelta},{#3-(#4)}) --++ (0,-3mm) ;
        \draw[pfltraitvoisinage,\tkzgraphcoulvoisin,pflflecheg] ({\tkzgraphvalavoisin+\pflvoisindelta},{#3+(#4)}) --++ (0,3mm) ;
      }%
      {%
        \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({\tkzgraphvalavoisin-\pflvoisindelta},{#3-(#4)}) --++ (0,-3mm) ;
        \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({\tkzgraphvalavoisin-\pflvoisindelta},{#3+(#4)}) --++ (0,3mm) ;
        \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({\tkzgraphvalavoisin+\pflvoisindelta},{#3-(#4)}) --++ (0,-3mm) ;
        \draw[pfltraitvoisinage,\tkzgraphcoulvoisin] ({\tkzgraphvalavoisin+\pflvoisindelta},{#3+(#4)}) --++ (0,3mm) ;
      }%
  }
  }%
}

%----COURBES PARAMETRIQUES
\NewDocumentCommand\DefinirCourbeParam{ O{} D<>{x} D<>{y} m m }{%
  \restoreKV[GraphiqueTikzCourbe]%
  \setKV[GraphiqueTikzCourbe]{#1}%
  \xintdeffloatfunc #2(t) := #4 ;
  \xintdeffloatfunc #3(t) := #5 ;
  %test dimension too large ??
  \ifboolKV[GraphiqueTikzCourbe]{Restreindre}%
  {%
    \xdef\pfloffsetV{\xintfloateval{((\pflymax)-(\pflymin))/20}}%
    \xdef\pflMinoffsetV{\xintfloateval{(\pflymin)-(\pfloffsetV)}}%
    \xdef\pflMaxoffsetV{\xintfloateval{(\pflymax)+(\pfloffsetV)}}%
    \xdef\pfloffsetH{\xintfloateval{((\pflxmax)-(\pflxmin))/20}}%
    \xdef\pflMinoffsetH{\xintfloateval{(\pflxmin)-(\pfloffsetH)}}%
    \xdef\pflMaxoffsetH{\xintfloateval{(\pflxmax)+(\pfloffsetH)}}%
  }%
  {}%
  %fin test
  \IfStrEq{\pflstepcurve}{}%
  {%
    \xdef\pflstepcurve{\xintfloateval{((\useKV[GraphiqueTikzCourbe]{Fin})-(\useKV[GraphiqueTikzCourbe]{Debut}))/250}}%
  }%
  {}%
  \ifboolKV[GraphiqueTikzCourbe]{Clip}{\begin{scope}\clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax});}{}
  \ifboolKV[GraphiqueTikzCourbe]{Trace}%
  {%
    \ifboolKV[GraphiqueTikzCourbe]{Restreindre}%
    {%
      \path[draw,pflcourbe,\pflstylecurve,{\useKV[GraphiqueTikzCourbe]{Couleur}},name path global=\pflnamecurve] plot[smooth] coordinates {%
        \xintthecoords\xintfloatexpr
          seq((min(max(#2(t),\pflMinoffsetH),\pflMaxoffsetH), min(max(#3(t),\pflMinoffsetV),\pflMaxoffsetV)),
          t=\useKV[GraphiqueTikzCourbe]{Debut}%
          ..[\pflstepcurve]..%
          \useKV[GraphiqueTikzCourbe]{Fin},
          \useKV[GraphiqueTikzCourbe]{Fin})
        \relax
      };
    }%
    {%
      \path[draw,pflcourbe,\pflstylecurve,{\useKV[GraphiqueTikzCourbe]{Couleur}},name path global=\pflnamecurve] plot[smooth] coordinates {%
        \xintthecoords\xintfloatexpr
          seq((#2(t),#3(t)),
          t=\useKV[GraphiqueTikzCourbe]{Debut}%
          ..[\pflstepcurve]..%
          \useKV[GraphiqueTikzCourbe]{Fin},
          \useKV[GraphiqueTikzCourbe]{Fin})
        \relax
      };
    }%
  }%
  {%
    \ifboolKV[GraphiqueTikzCourbe]{Restreindre}%
    {%
      \path[draw=none,pflcourbe,\pflstylecurve,{\useKV[GraphiqueTikzCourbe]{Couleur}},name path global=\pflnamecurve] plot[smooth] coordinates {%
        \xintthecoords\xintfloatexpr
        seq((min(max(#2(t),\pflMinoffsetH),\pflMaxoffsetH), min(max(#3(t),\pflMinoffsetV),\pflMaxoffsetV)),
        t=\useKV[GraphiqueTikzCourbe]{Debut}%
        ..[\pflstepcurve]..%
        \useKV[GraphiqueTikzCourbe]{Fin},
        \useKV[GraphiqueTikzCourbe]{Fin})
        \relax
      };
    }%
    {%
      \path[draw=none,pflcourbe,\pflstylecurve,{\useKV[GraphiqueTikzCourbe]{Couleur}},name path global=\pflnamecurve] plot[smooth] coordinates {%
        \xintthecoords\xintfloatexpr
          seq((#2(t),#3(t)),
          t=\useKV[GraphiqueTikzCourbe]{Debut}%
          ..[\pflstepcurve]..%
          \useKV[GraphiqueTikzCourbe]{Fin},
          \useKV[GraphiqueTikzCourbe]{Fin})
        \relax
      };
    }%
  }%
    \ifboolKV[GraphiqueTikzCourbe]{Clip}{\end{scope}}{}
}

\NewDocumentCommand\TracerCourbeParam{ O{} D<>{} m m }{%
  \restoreKV[GraphiqueTikzCourbe]%
  \setKV[GraphiqueTikzCourbe]{#1}%
  %test dimension too large ??
  \ifboolKV[GraphiqueTikzCourbe]{Restreindre}%
  {%
    \xdef\pfloffsetV{\xintfloateval{((\pflymax)-(\pflymin))/20}}%
    \xdef\pflMinoffsetV{\xintfloateval{(\pflymin)-(\pfloffsetV)}}%
    \xdef\pflMaxoffsetV{\xintfloateval{(\pflymax)+(\pfloffsetV)}}%
    \xdef\pfloffsetH{\xintfloateval{((\pflxmax)-(\pflxmin))/20}}%
    \xdef\pflMinoffsetH{\xintfloateval{(\pflxmin)-(\pfloffsetH)}}%
    \xdef\pflMaxoffsetH{\xintfloateval{(\pflxmax)+(\pfloffsetH)}}%
  }%
  {}%
  %fin test
  \IfStrEq{\pflstepcurve}{}%
  {%
    \xdef\pflstepcurve{\xintfloateval{((\useKV[GraphiqueTikzCourbe]{Fin})-(\useKV[GraphiqueTikzCourbe]{Debut}))/250}}%
  }%
  {}%
  \ifboolKV[GraphiqueTikzCourbe]{Clip}{\begin{scope}\clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax});}{}
  \IfEq{\pflnamecurve}{}%
  {%
    \ifboolKV[GraphiqueTikzCourbe]{RestreindreY}%
    {%
      \draw[pflcourbe,\pflstylecurve,{\useKV[GraphiqueTikzCourbe]{Couleur}}] plot[smooth] coordinates {%
        \xintthecoords\xintfloatexpr
          seq((min(max(#3,\pflMinoffsetH),\pflMaxoffsetH), min(max(#4,\pflMinoffsetV),\pflMaxoffsetV)),
          t=\useKV[GraphiqueTikzCourbe]{Debut}%
          ..[\pflstepcurve]..%
          \useKV[GraphiqueTikzCourbe]{Fin},
          \useKV[GraphiqueTikzCourbe]{Fin})
        \relax
      };
    }%
    {%
      \draw[pflcourbe,\pflstylecurve,{\useKV[GraphiqueTikzCourbe]{Couleur}}] plot[smooth] coordinates {%
        \xintthecoords\xintfloatexpr
          seq((#3,#4),
          t=\useKV[GraphiqueTikzCourbe]{Debut}%
          ..[\pflstepcurve]..%
          \useKV[GraphiqueTikzCourbe]{Fin},
          \useKV[GraphiqueTikzCourbe]{Fin})
        \relax
      };
    }%
  }%
  {%
    \ifboolKV[GraphiqueTikzCourbe]{RestreindreY}%
    {%
      \path[draw,pflcourbe,\pflstylecurve,{\useKV[GraphiqueTikzCourbe]{Couleur}},name path global=\pflnamecurve] plot[smooth] coordinates {%
        \xintthecoords\xintfloatexpr
          seq((min(max(#3,\pflMinoffsetH),\pflMaxoffsetH), min(max(#4,\pflMinoffsetV),\pflMaxoffsetV)),
          t=\useKV[GraphiqueTikzCourbe]{Debut}%
          ..[\pflstepcurve]..%
          \useKV[GraphiqueTikzCourbe]{Fin},
          \useKV[GraphiqueTikzCourbe]{Fin})
        \relax
      };
    }%
    {%
      \path[draw,pflcourbe,\pflstylecurve,{\useKV[GraphiqueTikzCourbe]{Couleur}},name path global=\pflnamecurve] plot[smooth] coordinates {%
        \xintthecoords\xintfloatexpr
          seq((#3,#4),
          t=\useKV[GraphiqueTikzCourbe]{Debut}%
          ..[\pflstepcurve]..%
          \useKV[GraphiqueTikzCourbe]{Fin},
          \useKV[GraphiqueTikzCourbe]{Fin})
          \relax
      };
    }%
  }%
  \ifboolKV[GraphiqueTikzCourbe]{Clip}{\end{scope}}{}
}

\NewDocumentCommand\DefinirCourbePol{ O{} D<>{phi} m }{%
  \restoreKV[GraphiqueTikzCourbe]%
  \setKV[GraphiqueTikzCourbe]{#1}%
  \xintdeffloatfunc #2(theta) := #3 ;%
  \DefinirCourbeParam[#1]<phix><phiy>{pflpol(t)*cos(t)}{pflpol(t)*sin(t)}%
}

\NewDocumentCommand\TracerCourbePol{ O{} m }{%
  \restoreKV[GraphiqueTikzCourbe]%
  \setKV[GraphiqueTikzCourbe]{#1}%
  \xintdeffloatfunc tmppflpol(theta) := #2 ;%
  \TracerCourbeParam[#1]{tmppflpol(t)*cos(t)}{tmppflpol(t)*sin(t)}%
}

%====MACRO INTERNE : nb dérivé via intersections (pour spline)
\NewDocumentCommand\tkzg@nbderive@spline{ m m m }{%
    \path[name path=pflvlineL] ({#2-#3},{\pflymin}) -- ({#2-#3},{\pflymax}) ;
    \path[name path=pflvlineR] ({#2+#3},{\pflymin}) -- ({#2+#3},{\pflymax}) ;
    \path[name intersections={of=#1 and pflvlineL, name=pflintL}] ;
    \path[name intersections={of=#1 and pflvlineR, name=pflintR}] ;
    \path (pflintL-1) ; \pgfgetlastxy{\macrox}{\macroy}%
    \xdef\tkzg@nbderivLY{\xintfloateval{(\ConvertirPtToCm{\macroy})/(\pflyunit)}}%
    \path (pflintR-1) ; \pgfgetlastxy{\macrox}{\macroy}%
    \xdef\tkzg@nbderivRY{\xintfloateval{(\ConvertirPtToCm{\macroy})/(\pflyunit)}}%
    \xdef\tkzg@nbderiv{\xintfloateval{(\tkzg@nbderivRY-\tkzg@nbderivLY)/(2*#3)}}%
}

%====TRACER LA DERIVEE NUMERIQUE D'UNE FONCTION NOMMEE OU D'UN SPLINE
\NewDocumentCommand\TracerDerivee{ O{} m }{%
  \restoreKV[GraphiqueTikzCourbe]%
  \setKV[GraphiqueTikzCourbe]{#1}%
  \IfStrEq{\pflstepcurve}{}%
    {\xdef\pflstepcurve{\xintfloateval{%
      ((\useKV[GraphiqueTikzCourbe]{Fin})-(\useKV[GraphiqueTikzCourbe]{Debut}))/100}}%
    }%
    {}%
  \IfStrEq{\pflhderiv}{}%
    {\ifboolKV[GraphiqueTikzCourbe]{Spline}%
      {\xdef\pflhderiv{\xintfloateval{0.5*\pflstepcurve}}}%
      {\def\pflhderiv{0.1}}%
    }%
    {}%
  \ifboolKV[GraphiqueTikzCourbe]{Spline}%
    {%
      % Bornes sécurisées
      \xdef\pfldebutderiv{\xintfloateval{(\useKV[GraphiqueTikzCourbe]{Debut})+\pflhderiv}}%
      \xdef\pflfinderiv{\xintfloateval{(\useKV[GraphiqueTikzCourbe]{Fin})-\pflhderiv}}%
      % Liste des xi
      \edef\pfllistexvals{\xintfloateval{%
        seq(x, x=\pfldebutderiv..[\pflstepcurve]..\pflfinderiv, \pflfinderiv)}}%
      % Construction de la liste de points (xi, f'(xi))
      \gdef\pfllistederivspline{}%
      \foreach \tmpxi in \pfllistexvals {%
        \tkzg@nbderive@spline{#2}{\tmpxi}{\pflhderiv}%
        \xdef\pfllistederivspline{\pfllistederivspline (\tmpxi,\tkzg@nbderiv)}%
      }%
      % Tracé
      \ifboolKV[GraphiqueTikzCourbe]{Clip}{\begin{scope}\clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax});}{}%
      \IfEq{\pflnamecurve}{}%
        {%
          \draw[pflcourbe,\pflstylecurve,{\useKV[GraphiqueTikzCourbe]{Couleur}}] plot[smooth] coordinates {\pfllistederivspline} ;
        }%
        {%
          \draw[pflcourbe,\pflstylecurve,{\useKV[GraphiqueTikzCourbe]{Couleur}},name path global=\pflnamecurve] plot[smooth] coordinates {\pfllistederivspline} ;
        }%
      \ifboolKV[GraphiqueTikzCourbe]{Clip}{\end{scope}}{}%
    }%
    {%
      % Bornes sécurisées : on recule de h de chaque côté (semble OK)
      \xdef\pfldebutderiv{\xintfloateval{(\useKV[GraphiqueTikzCourbe]{Debut})+\pflhderiv}}%
      \xdef\pflfinderiv  {\xintfloateval{(\useKV[GraphiqueTikzCourbe]{Fin})  -\pflhderiv}}%
      % Dérivée numérique centrée
      \xintdeffloatfunc pflnumderiv(x) :=  (#2(x+\pflhderiv) - #2(x-\pflhderiv)) / (2*\pflhderiv);%
      % Tracé
      \ifboolKV[GraphiqueTikzCourbe]{Clip}%
      {\begin{scope}\clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax});}{}%
        \IfEq{\pflnamecurve}{}%
          {%
            \draw[pflcourbe,\pflstylecurve,{\useKV[GraphiqueTikzCourbe]{Couleur}}]
              plot[smooth] coordinates {%
                \xintthecoords\xintfloatexpr
                seq((x,pflnumderiv(x)),
                x=\pfldebutderiv..[\pflstepcurve]..\pflfinderiv,
                \pflfinderiv)
                \relax
              };%
          }%
          {%
            \draw[pflcourbe,\pflstylecurve,{\useKV[GraphiqueTikzCourbe]{Couleur}},name path global=\pflnamecurve]
              plot[smooth] coordinates {%
                \xintthecoords\xintfloatexpr
                seq((x,pflnumderiv(x)),
                x=\pfldebutderiv..[\pflstepcurve]..\pflfinderiv,
                \pflfinderiv)
                \relax
              };%
          }%
        \ifboolKV[GraphiqueTikzCourbe]{Clip}{\end{scope}}{}%
        }%
}

\NewDocumentCommand\TracerPrimitive{ O{} m m m }{%
  % #1 = options KV (Couleur, Debut, Fin, Pas, Clip, StyleTrace...)
  % #2 = nom de la fonction (définie via \DefinirCourbe)
  % #3 = x0 (abscisse du point de passage)
  % #4 = y0 (ordonnée du point de passage)
  \restoreKV[GraphiqueTikzCourbe]%
  \setKV[GraphiqueTikzCourbe]{#1}%
  % Pas de tracé par défaut
  \IfStrEq{\pflstepcurve}{}%
    {\xdef\pflstepcurve{\xintfloateval{%
      ((\useKV[GraphiqueTikzCourbe]{Fin})-(\useKV[GraphiqueTikzCourbe]{Debut}))/100}}}%
    {}%
  % Bornes sécurisées (comme pour \TracerDerivee)
  \xdef\pfldebutprim{\xintfloateval{(\useKV[GraphiqueTikzCourbe]{Debut})+\pflstepcurve/10}}%
  \xdef\pflfinprim  {\xintfloateval{(\useKV[GraphiqueTikzCourbe]{Fin})  -\pflstepcurve/10}}%
  % Primitive numérique — méthode des trapèzes, gestion des deux sens
  \xintdeffloatfunc pflnumprimitive(x) :=
    (x > #3) ?
      {%  x à droite de x0 : intégrale de x0 à x
        #4 + \pflstepcurve*(
          #2(#3)/2
          + add(#2(t), t=(#3+\pflstepcurve)..[(\pflstepcurve)]..(x-\pflstepcurve))
          + #2(x)/2
        )
      }
      { (x < #3) ?
        {%  x à gauche de x0 : intégrale de x à x0, changement de signe
          #4 - \pflstepcurve*(
            #2(x)/2
            + add(#2(t), t=(x+\pflstepcurve)..[(\pflstepcurve)]..(#3-\pflstepcurve))
            + #2(#3)/2
          )
        }
        { #4 }%  x == x0 exactement
      };%
  % Tracé
  \ifboolKV[GraphiqueTikzCourbe]{Clip}%
    {\begin{scope}\clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax});}{}%
  \IfEq{\pflnamecurve}{}%
    {%
      \draw[pflcourbe,\pflstylecurve,{\useKV[GraphiqueTikzCourbe]{Couleur}}]
        plot[smooth] coordinates {%
          \xintthecoords\xintfloatexpr
          seq((x,pflnumprimitive(x)),
              x=\pfldebutprim..[\pflstepcurve]..\pflfinprim,
              \pflfinprim)
          \relax
        };%
    }%
    {%
      \path[draw,pflcourbe,\pflstylecurve,{\useKV[GraphiqueTikzCourbe]{Couleur}},name path global=\pflnamecurve]
        plot[smooth] coordinates {%
          \xintthecoords\xintfloatexpr
          seq((x,pflnumprimitive(x)),
              x=\pfldebutprim..[\pflstepcurve]..\pflfinprim,
              \pflfinprim)
          \relax
        };%
    }%
  \ifboolKV[GraphiqueTikzCourbe]{Clip}{\end{scope}}{}%
}

\NewDocumentCommand\DefinirListeInterpo{ m O{\malisteinterpo} }{%
  \def#2{#1}%
}

\NewDocumentCommand\DefinirCourbeInterpo{ O{} m }{%
  \restoreKV[GraphiqueTikzCourbe]%
  \setKV[GraphiqueTikzCourbe]{#1}%
  \begin{scope}
    \ifboolKV[GraphiqueTikzCourbe]{Trace}%
      {%
        \path[draw,pflcourbe,\pflstylecurve,{\useKV[GraphiqueTikzCourbe]{Couleur}},name path global=\pflnamecurve] plot[smooth,tension={\useKV[GraphiqueTikzCourbe]{Tension}}] coordinates {#2};
      }%
      {%
        \path[draw=none,pflcourbe,{\useKV[GraphiqueTikzCourbe]{Couleur}},name path global=\pflnamecurve] plot[smooth,tension={\useKV[GraphiqueTikzCourbe]{Tension}}] coordinates {#2};
      }%
  \end{scope}
}

\NewDocumentCommand\TracerCourbeInterpo{ O{} m }{%
  %2=liste
  \restoreKV[GraphiqueTikzCourbe]%
  \setKV[GraphiqueTikzCourbe]{#1}%
  \begin{scope}
    \draw[pflcourbe,\pflstylecurve,{\useKV[GraphiqueTikzCourbe]{Couleur}}] plot [smooth,tension={\useKV[GraphiqueTikzCourbe]{Tension}}] coordinates {#2} ;
  \end{scope}
}

\NewDocumentCommand\DefinirListeSpline{ m O{\malistespline} }{%
  \def#2{#1}%
}

\newcommand\pflextractcoeff[2]{%1=liste,2=numero
  \setsepchar{§}%
  \readlist*\lcoeffs{#1}
  \ifnum \lcoeffslen=1
    \def\COEFFA{#1}
    \def\COEFFB{#1}
  \else
    \itemtomacro\lcoeffs[#2]\COEFF
    \IfSubStr{\COEFF}{/}%
      {\StrCut{\COEFF}{/}{\COEFFA}{\COEFFB}}%
      {\def\COEFFA{\COEFF}\def\COEFFB{\COEFF}}
  \fi
}

\defKV[GraphiqueTikzSpline]{%
  Nom=\def\pflsplinename{#1},%
  Coeffs=\def\pflsplinecoeffs{#1},%
  StyleTrace=\def\pflsplinestyle{#1}
}

\setKVdefault[GraphiqueTikzSpline]{%
  Nom=spline,%
  Couleur=black,%
  Coeffs=3,%
  Trace=false,%
  Alt=false,%
  StyleTrace={}
}

\NewDocumentCommand\GenererSpline{ s m m O{\monspline} }{%
  %1=liste
  \setsepchar[.]{§./}%
  \readlist*\SPLlistepoints{#2}%
  %les données
  \def\tmpsplinenumdeb{1}
  \def\tmpsplinenumfin{\SPLlistepointslen}%
  \pflextractcoeff{#3}{\tmpsplinenumdeb}%
  %nb de calculs
  \def\SPLnbsplines{\inteval{\tmpsplinenumfin-1}}%
  %extraction des coordonnées
  \itemtomacro\SPLlistepoints[\tmpsplinenumdeb,1]\xa%
  \itemtomacro\SPLlistepoints[\tmpsplinenumdeb,2]\ya%
  \itemtomacro\SPLlistepoints[\tmpsplinenumdeb,3]\fprimea%
  \itemtomacro\SPLlistepoints[\tmpsplinenumdeb,1]\xb%
  \itemtomacro\SPLlistepoints[\tmpsplinenumdeb,2]\yb%
  \itemtomacro\SPLlistepoints[\tmpsplinenumdeb,3]\fprimeb%
  \IfBooleanTF{#1}%
  {%
    % mode Alt : on garde le signe de (xb-xa), pas de abs()
    \xdef#4{(\xa,\ya) ..controls +({((\xb)-(\xa))/\COEFFA},{(\fprimea)*((\xb)-(\xa))/\COEFFA}) and +({-((\xb)-(\xa))/\COEFFA},{-(\fprimeb)*((\xb)-(\xa))/\COEFFA}).. (\xb,\yb)}%
  }%
  {%
    % mode polaire : abs() sur le rayon uniquement
    \xdef#4{(\xa,\ya) ..controls +({atan (\fprimea)}:{((\xb)-(\xa))/\COEFFA}) and +({-180 + atan (\fprimeb)}:{((\xb)-(\xa))/\COEFFA}).. (\xb,\yb)}%
  }%
  \foreach \i in {\tmpsplinenumdeb,...,\SPLnbsplines}{%
    \pflextractcoeff{#3}{\i}%
    \def\j{\inteval{\i+1}}%
    \itemtomacro\SPLlistepoints[\i,1]\xa%
    \itemtomacro\SPLlistepoints[\i,2]\ya%
    \itemtomacro\SPLlistepoints[\i,3]\fprimea%
    \itemtomacro\SPLlistepoints[\j,1]\xb%
    \itemtomacro\SPLlistepoints[\j,2]\yb%
    \itemtomacro\SPLlistepoints[\j,3]\fprimeb%
    \IfBooleanTF{#1}%
    {%
      \xdef#4{#4 ..controls +({((\xb)-(\xa))/\COEFFA},{(\fprimea)*((\xb)-(\xa))/\COEFFA}) and +({-((\xb)-(\xa))/\COEFFA},{-(\fprimeb)*((\xb)-(\xa))/\COEFFA}).. (\xb,\yb)}%
    }%
    {%
      \xdef#4{#4 ..controls +({atan (\fprimea)}:{((\xb)-(\xa))/\COEFFA}) and +({-180 + atan (\fprimeb)}:{((\xb)-(\xa))/\COEFFB}).. (\xb,\yb)}%
    }%
  }%
}

\NewDocumentCommand\DefinirCourbeSpline{ O{} m D<>{\monspline} }{%
  %1=liste
  \restoreKV[GraphiqueTikzSpline]%
  \setKV[GraphiqueTikzSpline]{#1}%
  \ifboolKV[GraphiqueTikzSpline]{Alt}%
    {%
      \GenererSpline*{#2}{\pflsplinecoeffs}[#3]%
    }%
    {%
      \GenererSpline{#2}{\pflsplinecoeffs}[#3]%
    }%
  \begin{scope}
    \ifboolKV[GraphiqueTikzSpline]{Trace}%
      {%
        \path[draw,pflcourbe,\pflsplinestyle,{\useKV[GraphiqueTikzSpline]{Couleur}},name path global=\pflsplinename] #3 ;
      }%
      {%
        \path[draw=none,pflcourbe,name path global=\pflsplinename] #3 ;
      }%
  \end{scope}
}

\NewDocumentCommand\DefinirSpline{ O{} m D<>{\monspline} }{%old version
  %1=liste
  \restoreKV[GraphiqueTikzSpline]%
  \setKV[GraphiqueTikzSpline]{#1}%
  \GenererSpline{#2}{\pflsplinecoeffs}[#3]%
  \begin{scope}
    \ifboolKV[GraphiqueTikzSpline]{Trace}%
      {%
        \path[draw,pflcourbe,\pflsplinestyle,{\useKV[GraphiqueTikzSpline]{Couleur}},name path global=\pflsplinename] #3 ;
      }%
      {%
        \path[draw=none,pflcourbe,name path global=\pflsplinename] #3 ;
      }%
  \end{scope}
}

\NewDocumentCommand\TracerCourbeSpline{ O{} m D<>{\monspline} }{%
  %1=liste
  \restoreKV[GraphiqueTikzSpline]%
  \setKV[GraphiqueTikzSpline]{#1}%
  \ifboolKV[GraphiqueTikzSpline]{Alt}%
    {%
      \GenererSpline*{#2}{\pflsplinecoeffs}[#3]%
    }%
    {%
      \GenererSpline{#2}{\pflsplinecoeffs}[#3]%
    }%
  \begin{scope}
    \draw[pflcourbe,\pflsplinestyle,{\useKV[GraphiqueTikzSpline]{Couleur}}] #3 ;
  \end{scope}
}

\NewDocumentCommand\TracerSpline{ O{} m D<>{\monspline} }{%old version
  %1=liste
  \restoreKV[GraphiqueTikzSpline]%
  \setKV[GraphiqueTikzSpline]{#1}%
  \GenererSpline{#2}{\pflsplinecoeffs}[#3]%
  \begin{scope}
    \draw[pflcourbe,\pflsplinestyle,{\useKV[GraphiqueTikzSpline]{Couleur}}] #3 ;
  \end{scope}
}

%===INTERSECTION & ANTÉCÉDENTS
\defKV[GraphiqueTikzIntersect]{%
  Nom=\def\pflintercurves{#1}
}
\setKVdefault[GraphiqueTikzIntersect]{%
  Nom=S,
  Aff=true,
  Couleur=black,
  AffDroite=false,%
  Traits=false,%
  Style=o
}

\NewDocumentCommand\TrouverIntersections{ O{} m m D<>{\myt} }{%
  \restoreKV[GraphiqueTikzIntersect]%
  \setKV[GraphiqueTikzIntersect]{#1}%
  \path[name intersections={of=#2 and #3,name=\pflintercurves,total=\t}] \pgfextra{\xdef#4{\t}};
  \ifboolKV[GraphiqueTikzIntersect]{Aff}%
    {%
      \xintifboolexpr{#4 == 0}{}%
        {%
          \foreach \i in {1,...,#4}{%
            \ifboolKV[GraphiqueTikzIntersect]{Traits}%
              {%
                \draw[pfltraitimg,{\useKV[GraphiqueTikzIntersect]{Couleur}}]let \p1 = (\pflintercurves-\i) in (\pflintercurves-\i) -- ({\x1},{\pflOy}) ;
              }%
              {}%
            \MarquerPts*[Style={\useKV[GraphiqueTikzIntersect]{Style}},Couleur={\useKV[GraphiqueTikzIntersect]{Couleur}}]{(\pflintercurves-\i)}
            %\filldraw[{\useKV[GraphiqueTikzIntersect]{Couleur}}] (\pflintercurves-\i) circle[pflpointc] ;
          }
        }%
    }%
    {}%
}

\NewDocumentCommand\TrouverAntecedents{ O{} m m D<>{\myantec} }{%
  \restoreKV[GraphiqueTikzIntersect]%
  \setKV[GraphiqueTikzIntersect]{#1}%
  \begin{scope}
    \clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax});
    \ifboolKV[GraphiqueTikzIntersect]{AffDroite}%
      {%
        \path[draw,{\useKV[GraphiqueTikzIntersect]{Couleur}},pflcourbe,name path=tmpanteced] ({\pflxmin},{#3})--({\pflxmax},{#3}) ;
      }%
      {%
        \path[draw=none,pflcourbe,name path=tmpanteced] ({\pflxmin},{#3})--({\pflxmax},{#3}) ;
      }%
    \path[name intersections={of=#2 and tmpanteced,name=\pflintercurves,total=\t}] \pgfextra{\xdef#4{\t}};
    \ifboolKV[GraphiqueTikzIntersect]{Aff}%
      {%
        \xintifboolexpr{#4 == 0}{}%
        {%
          \foreach \i in {1,...,#4}{%
            \MarquerPts*[Style={\useKV[GraphiqueTikzIntersect]{Style}},Couleur={\useKV[GraphiqueTikzIntersect]{Couleur}}]{(\pflintercurves-\i)}
            %\filldraw[{\useKV[GraphiqueTikzIntersect]{Couleur}}] (\pflintercurves-\i) circle[pflpointc] ;
          }
        }%
      }%
      {}%
  \end{scope}
}

%====MONTE CARLO
\defKV[graphiquetikzmontecarlo]{%
  Couleurs=\def\graphtikzmccols{#1},%
  BornesX=\def\graphtikzmcxbornes{#1},%
  BornesY=\def\graphtikzmcybornes{#1}
}

\setKVdefault[graphiquetikzmontecarlo]{%
  Couleurs={blue/red},%
  BornesX={\pflxmin,\pflxmax},%
  BornesY={\pflymin,\pflymax}
}

\NewDocumentCommand\SimulerMonteCarlo{ O{} D<>{f} m O{\nbptsmcok} O{\nbptsmcko} }{%
  \restoreKV[graphiquetikzmontecarlo]%
  \setKV[graphiquetikzmontecarlo]{#1}%
  \StrCut{\graphtikzmccols}{/}{\tmpMCcolOK}{\tmpMCcolKO}%
  \StrCut{\graphtikzmcxbornes}{,}{\tmpMCxmin}{\tmpMCxmax}%
  \StrCut{\graphtikzmcybornes}{,}{\tmpMCymin}{\tmpMCymax}%
  \xdef#4{0}%
  \xdef#5{0}%
  \xdef\nbptsmc{#3}%
  \foreach \i in {1,...,#3}{%
    \xdef\tmpMCrandX{\xintfloateval{random()*((\tmpMCxmax)-(\tmpMCxmin))+(\tmpMCxmin)}}%
    \xdef\tmpMCrandY{\xintfloateval{random()*((\tmpMCymax)-(\tmpMCymin))+(\tmpMCymin)}}%
    \xdef\tmpMCrandfX{\xintfloateval{#2(\tmpMCrandX)}}%
    \xintifboolexpr{ \tmpMCrandfX  > \tmpMCrandY }%
      {%
        \xdef#4{\xinteval{#4+1}}%
        \filldraw[\tmpMCcolOK] (\tmpMCrandX,\tmpMCrandY) circle[pflpointmc] ;
      }%
      {%
        \xdef#5{\xinteval{#5+1}}%
        \filldraw[\tmpMCcolKO] (\tmpMCrandX,\tmpMCrandY) circle[pflpointmc] ;
      }%
  }%
}

%====MÉTHODES INTÉGRALES
\defKV[graphiquetikzintegr]{%
  Couleur=\def\graphtikzintgrcol{#1},%
  CouleurRemplissage=\def\graphtikzintgrcolrempl{#1},%
  NbSubDiv=\def\graphtikzintgrnb{#1},%
  Methode=\def\graphtikzintgrtype{#1},%
  Opacite=\def\graphtikzintgropac{#1}
}

\setKVdefault[graphiquetikzintegr]{%
  Couleur=red,%
  NbSubDiv=10,%
  Methode=RectanglesGauche,%
  Remplir=true,%
  CouleurRemplissage={\graphtikzintgrcol!25},%
  Opacite=0.25,%
  Spline=false
}

\NewDocumentCommand\RepresenterMethodeIntegrale{ O{} D<>{f} m m }{%opts+nom_fct/spline+a+b
  \useKVdefault[graphiquetikzintegr]%
  \setKV[graphiquetikzintegr]{#1}%
  \ifboolKV[graphiquetikzintegr]{Remplir}%
    {%
      \tikzset{pflfigureintegr/.style={pfltrait,\graphtikzintgrcol,fill=\graphtikzintgrcolrempl,fill opacity=\graphtikzintgropac}}%
    }%
    {%
      \tikzset{pflfigureintegr/.style={pfltrait,\graphtikzintgrcol}}%
    }%
  \tikzset{figureintegr/.style={pfltrait,\graphtikzintgrcol,fill=\graphtikzintgrcolrempl,fill opacity=\graphtikzintgropac}}%
  \def\TmpH{(#4-#3)/\graphtikzintgrnb}
  \ifboolKV[graphiquetikzintegr]{Spline}%
    {%
      \IfEq{\graphtikzintgrtype}{RectanglesGauche}%
        {%
          \foreach \i in {0,...,\inteval{\graphtikzintgrnb-1}}{%
            \path[draw=none,pflcourbe,name path=tmpintmethod] ({#3+\i*\TmpH},{\pflymin})--({#3+\i*\TmpH},{\pflymax}) ;
            \path[name intersections={of=#2 and tmpintmethod,name=KLM}] ;
            \draw[pflfigureintegr] let \p1 = (KLM-1) in ({#3+\i*\TmpH},{0}) rectangle++ ({\TmpH},{\y1}) ;
          }%
        }%
        {}%
      \IfEq{\graphtikzintgrtype}{RectanglesDroite}%
        {%
          \foreach \i in {0,...,\inteval{\graphtikzintgrnb-1}}{%
            \path[draw=none,pflcourbe,name path=tmpintmethod] ({#3+(\i+1)*\TmpH},{\pflymin})--({#3+(\i+1)*\TmpH},{\pflymax}) ;
            \path[name intersections={of=#2 and tmpintmethod,name=KLM}] ;
            \draw[pflfigureintegr] let \p1 = (KLM-1) in ({#3+\i*\TmpH},{0}) rectangle++ ({\TmpH},{\y1}) ;
          }%
        }%
        {}%
      \IfEq{\graphtikzintgrtype}{RectanglesMilieu}%
        {%
          \foreach \i in {0,...,\inteval{\graphtikzintgrnb-1}}{%
            \path[draw=none,pflcourbe,name path=tmpintmethod] ({#3+(\i+0.5)*\TmpH},{\pflymin})--({#3+(\i+0.5)*\TmpH},{\pflymax}) ;
            \path[name intersections={of=#2 and tmpintmethod,name=KLM}] ;
            \draw[pflfigureintegr] let \p1 = (KLM-1) in ({#3+\i*\TmpH},{0}) rectangle++ ({\TmpH},{\y1}) ;
          }%
        }%
        {}%
      \IfEq{\graphtikzintgrtype}{Trapezes}%
        {%
          \foreach \i in {0,...,\inteval{\graphtikzintgrnb-1}}{%
            \path[draw=none,pflcourbe,name path=tmpintmethodg] ({#3+(\i)*\TmpH},{\pflymin})--({#3+(\i)*\TmpH},{\pflymax}) ;
            \path[name intersections={of=#2 and tmpintmethodg,name=KLMg}] ;
            \path[draw=none,pflcourbe,name path=tmpintmethodd] ({#3+(\i+1)*\TmpH},{\pflymin})--({#3+(\i+1)*\TmpH},{\pflymax}) ;
            \path[name intersections={of=#2 and tmpintmethodd,name=KLMd}] ;
            \draw[pflfigureintegr] ({#3+\i*\TmpH},{0}) -- (KLMg-1) -- (KLMd-1) -- ({#3+(\i+1)*\TmpH},{0}) -- cycle ;
          }%
        }%
        {}%
    }%
    {%
      \IfEq{\graphtikzintgrtype}{RectanglesGauche}%
        {%
          \foreach \i in {0,...,\inteval{\graphtikzintgrnb-1}}%
            \draw[pflfigureintegr] ({#3+\i*\TmpH},{0}) rectangle++ ({\TmpH},{\xintfloateval{#2(#3+\i*\TmpH)}}) ;
        }%
        {}%
      \IfEq{\graphtikzintgrtype}{RectanglesDroite}%
        {%
          \foreach \i in {0,...,\inteval{\graphtikzintgrnb-1}}%
            \draw[pflfigureintegr] ({#3+\i*\TmpH},{0}) rectangle++ ({\TmpH},{\xintfloateval{#2(#3+(\i+1)*\TmpH)}}) ;
        }%
        {}%
      \IfEq{\graphtikzintgrtype}{RectanglesMilieu}%
        {%
          \foreach \i in {0,...,\inteval{\graphtikzintgrnb-1}}%
            \draw[pflfigureintegr] ({#3+\i*\TmpH},{0}) rectangle++ ({\TmpH},{\xintfloateval{#2(#3+(\i+0.5)*\TmpH)}}) ;
        }%
        {}%
      \IfEq{\graphtikzintgrtype}{Trapezes}%
        {%
          \foreach \i in {0,...,\inteval{\graphtikzintgrnb-1}}%
            \draw[pflfigureintegr] ({#3+\i*\TmpH},{0}) -- ({#3+\i*\TmpH},{\xintfloateval{#2(#3+\i*\TmpH)}}) -- ({#3+(\i+1)*\TmpH},{\xintfloateval{#2(#3+(\i+1)*\TmpH)}}) -- ({#3+(\i+1)*\TmpH},{0}) -- cycle ;
        }%
        {}%
    }%
}

%====INTÉGRALES
%v2 avec modification de la clé [Type=...] ?
\defKV[GraphiqueTikzIntegr]{%
  Couleurs=\def\pfldomtikzcolors{#1},%
  Style=\def\pfldomtikzstyle{#1},%
  Opacite=\def\pfldomtikzopac{#1},%
  Hachures=\def\pfldomtikzhatch{#1},%
  Type=\def\pfldomtikztype{#1},%
  Pas=\def\pflstepcurve{#1},%
  Bornes=\def\pflintbornes{#1},%
  Jonction=\def\pfldomtikzjoin{#1},%
  NomInterpo=\def\pfldomtikznameinterpo{#1},%
  NomInterpoB=\def\pfldomtikznameinterpob{#1},%
  NomSpline=\def\pfldomtikznamespline{#1},%
  NomSplineB=\def\pfldomtikznamesplineb{#1}
}
\setKVdefault[GraphiqueTikzIntegr]{%
  Couleurs=gray,%
  Style=remplissage,%
  Opacite=0.5,%
  Hachures={north west lines},%
  Type=fct,%
  Pas={},%
  Jonction=bevel,%
  Bornes=abs,%
  Bord=true,%
  Spline=false,%
  SplineB=false,%
  NomInterpo={\moninterpo},%
  NomInterpoB={\moninterpoB},%
  NomSpline={\monspline},%
  NomSplineB={\monsplineB},%
  Tension=0.5,%
  TensionB=0.5
}

\NewDocumentCommand\TracerIntegrale{ O{} D<>{} m O{0} m m }{%
  %1 = clés
  %2 = options particulières tikz
  %3 = fonction, en tikz
  %4 = fonction n°2 éventuelle
  %de #5 à #6
  \restoreKV[GraphiqueTikzIntegr]% revenir au valeurs par défaut
  \setKV[GraphiqueTikzIntegr]{#1}% lit les arguments optionnels
  %les couleurs
  \IfSubStr{\pfldomtikzcolors}{/}%
    {%
      \StrCut{\pfldomtikzcolors}{/}{\pfldomtikzcolorbord}{\pfldomtikzcolorfond}
    }%
    {%
      \xdef\pfldomtikzcolorbord{\pfldomtikzcolors}\xdef\pfldomtikzcolorfond{\pfldomtikzcolors}
    }%
  \ifboolKV[GraphiqueTikzIntegr]{Bord}%
    {%
      \tikzset{integralebordtikzstyle/.style={draw=\pfldomtikzcolorbord}}
    }%
    {%
      \tikzset{integralebordtikzstyle/.style={draw=none}}
    }%
  \IfStrEq{\pfldomtikzstyle}{hachures}%
    {%
      \tikzset{integraletikzstyle/.style={pfltrait,pattern=\pfldomtikzhatch,pattern color=\pfldomtikzcolorfond,line join=\pfldomtikzjoin}}
    }%
    {}%
  \IfStrEq{\pfldomtikzstyle}{remplissage}%
    {%
      \tikzset{integraletikzstyle/.style={pfltrait,fill=\pfldomtikzcolorfond,fill opacity=\pfldomtikzopac,line join=\pfldomtikzjoin}}
    }%
    {}%
  %extraction des infos x/y
  \IfStrEqCase{\pflintbornes}{%
    {abs}%
    {%
      \xdef\absnoeudA{#5}%
      \xdef\absnoeudB{#6}%
    }%
    {noeuds}%
    {%
      \path #5;
      \pgfgetlastxy{\macrox}{\macroy}%
      \xdef\absnoeudA{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
      \path #6;
      \pgfgetlastxy{\macrox}{\macroy}%
      \xdef\absnoeudB{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
    }%
    {abs/noeud}%
    {%
      \xdef\absnoeudA{#5}%
      \path #6;
      \pgfgetlastxy{\macrox}{\macroy}%
      \xdef\absnoeudB{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
    }%
    {noeud/abs}%
    {%
      \path #5;
      \pgfgetlastxy{\macrox}{\macroy}%
      \xdef\absnoeudA{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
      \xdef\absnoeudB{#6}%
    }%
  }%
  %suite avec les nbs points
  \IfStrEq{\pflstepcurve}{}%
    {%
      \xdef\pflstepcurve{\xintfloateval{((\absnoeudB)-(\absnoeudA))/100}}%
    }%
    {}%
  %TRACÉSen fonction des types de courbes
  \IfStrEq{\pfldomtikztype}{fct}%
    {%OK
      \begin{scope}
        \clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax});
        \draw[integraletikzstyle,integralebordtikzstyle,#2] ({\absnoeudA},{\pflOy}) -- plot[smooth] coordinates {\xintthecoords\xintfloatexpr seq((x,#3),x=\absnoeudA..[\pflstepcurve]..\absnoeudB,\absnoeudB)\relax} -- ({\absnoeudB},{\pflOy}) -- cycle ;
      \end{scope}
    }%
    {}%
  \IfStrEq{\pfldomtikztype}{spl}%avec 3=courbe spline + clé [Spline] à utiliser !
    {%OK
      \begin{scope}
        \clip ({\absnoeudA},{\pflymin}) rectangle ({\absnoeudB},{\pflymax}) ;
        \filldraw[integraletikzstyle,integralebordtikzstyle,#2] ({\absnoeudA},{\pflOy}) -- \pfldomtikznamespline -- ({\absnoeudB},{\pflOy}) -- cycle ;
      \end{scope}
      \path[draw=none,pflcourbe,name path=tmpintbornea] ({\absnoeudA},{\pflymin})--({\absnoeudA},{\pflymax}) ;
      \path[name intersections={of=#3 and tmpintbornea,name=YYY}] ;
      \draw[\pfldomtikzcolorbord,pfltrait] ({\absnoeudA},{\pflOy})-- (YYY-1) ;
      \path[draw=none,pflcourbe,name path=tmpintborneb] ({\absnoeudB},{\pflymin})--({\absnoeudB},{\pflymax}) ;
      \path[name intersections={of=#3 and tmpintborneb,name=ZZZ}] ;
      \draw[\pfldomtikzcolorbord,pfltrait] ({\absnoeudB},{\pflOy})-- (ZZZ-1) ;
    }%
    {}%
  \IfStrEq{\pfldomtikztype}{itp}%avec 3=courbe interpo
    {%OK
      \begin{scope}
        \clip ({\absnoeudA},{\pflymin}) rectangle ({\absnoeudB},{\pflymax}) ;
        \filldraw[integraletikzstyle,integralebordtikzstyle,#2] ({\absnoeudA},{\pflOy}) -- plot [smooth,tension={\useKV[GraphiqueTikzIntegr]{Tension}}] coordinates {#3} -- ({\absnoeudB},{\pflOy}) -- cycle ;
      \end{scope}
      \path[draw=none,pflcourbe,name path=tmpintbornea] ({\absnoeudA},{\pflymin})--({\absnoeudA},{\pflymax}) ;
      \path[name intersections={of=tmpintbornea and \pfldomtikznameinterpo,name=YYY}] ;
      \draw[\pfldomtikzcolorbord,pfltrait] ({\absnoeudA},{\pflOy})-- (YYY-1) ;
      \path[draw=none,pflcourbe,name path=tmpintborneb] ({\absnoeudB},{\pflymin})--({\absnoeudB},{\pflymax}) ;
      \path[name intersections={of=tmpintborneb and \pfldomtikznameinterpo,name=ZZZ}] ;
      \draw[\pfldomtikzcolorbord,pfltrait] ({\absnoeudB},{\pflOy})-- (ZZZ-1) ;
    }%
    {}%
  \IfStrEq{\pfldomtikztype}{fct/fct}%avec #3=formule et #4=formule
    {%
      \begin{scope}
        \clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax});
        \draw[integraletikzstyle,integralebordtikzstyle,#2] plot[smooth] coordinates {\xintthecoords\xintfloatexpr seq((x,#3),x=\absnoeudA..[\pflstepcurve]..\absnoeudB,\absnoeudB)\relax} -- plot[smooth] coordinates {\xintthecoords\xintfloatexpr seq((x,#4),x=\absnoeudB..[-(\pflstepcurve)]..\absnoeudA,\absnoeudA)\relax} -- cycle ;
      \end{scope}
    }%
    {}%
  \IfStrEq{\pfldomtikztype}{spl/spl}%avec #3=cbe spline + #4=cbe splineB
    {%
      \begin{scope}
        \clip ({\absnoeudA},{\pflymin}) rectangle ({\absnoeudB},{\pflymax}) ;
        \clip ({\absnoeudA},{\pflymin}) -- \pfldomtikznamespline -- ({\absnoeudB},{\pflymin}) -- cycle ;
        \clip ({\absnoeudA},{\pflymax}) -- \pfldomtikznamesplineb -- ({\absnoeudB},{\pflymax}) -- cycle ;
        \filldraw[integraletikzstyle,integralebordtikzstyle,#2] ({\absnoeudA},{\pflymin}) rectangle ({\absnoeudB},{\pflymax}) ;
      \end{scope}
      \path[draw=none,pflcourbe,name path=tmpintbornea] ({\absnoeudA},{\pflymin})--({\absnoeudA},{\pflymax}) ;
      \path[name intersections={of=#3 and tmpintbornea,name=YYYA}] ;
      \path[name intersections={of=#4 and tmpintbornea,name=ZZZA}] ;
      \path[draw=none,pflcourbe,name path=tmpintborneb] ({\absnoeudB},{\pflymin})--({\absnoeudB},{\pflymax}) ;
      \path[name intersections={of=#3 and tmpintborneb,name=YYYB}] ;
      \path[name intersections={of=#4 and tmpintborneb,name=ZZZB}] ;
      \draw[\pfldomtikzcolorbord,pfltrait] (YYYA-1)-- (ZZZA-1) ;
      \draw[\pfldomtikzcolorbord,pfltrait] (YYYB-1)-- (ZZZB-1) ;
    }%
    {}%
  \IfStrEq{\pfldomtikztype}{itp/itp}%avec #3=cbe interpo + #4=cbe interpoB
    {%
      \begin{scope}
        \clip ({\absnoeudA},{\pflymin}) rectangle ({\absnoeudB},{\pflymax}) ;
        \clip ({\absnoeudA},{\pflymin}) -- plot [smooth,tension={\useKV[GraphiqueTikzIntegr]{Tension}}] coordinates {#3} -- ({\absnoeudB},{\pflymin}) ;
        \clip ({\absnoeudA},{\pflymax}) -- plot [smooth,tension={\useKV[GraphiqueTikzIntegr]{TensionB}}] coordinates {#4} -- ({\absnoeudB},{\pflymax}) ;
        \filldraw[integraletikzstyle,integralebordtikzstyle,#2] ({\absnoeudA},{\pflymin}) rectangle ({\absnoeudB},{\pflymax}) ;
      \end{scope}
      \path[draw=none,pflcourbe,name path=tmpintbornea] ({\absnoeudA},{\pflymin})--({\absnoeudA},{\pflymax}) ;
      \path[name intersections={of=tmpintbornea and \pfldomtikznameinterpo,name=YYYA}] ;
      \path[name intersections={of=tmpintbornea and \pfldomtikznameinterpob,name=ZZZA}] ;
      \path[draw=none,pflcourbe,name path=tmpintborneb] ({\absnoeudB},{\pflymin})--({\absnoeudB},{\pflymax}) ;
      \path[name intersections={of=tmpintborneb and \pfldomtikznameinterpo,name=YYYB}] ;
      \path[name intersections={of=tmpintborneb and \pfldomtikznameinterpob,name=ZZZB}] ;
      \draw[\pfldomtikzcolorbord,pfltrait] (YYYA-1)-- (ZZZA-1) ;
      \draw[\pfldomtikzcolorbord,pfltrait] (YYYB-1)-- (ZZZB-1) ;
    }%
    {}%
  \IfStrEq{\pfldomtikztype}{fct/spl}%avec #3=formule + #4=spline
    {%
      \begin{scope}
        \clip ({\absnoeudA},{\pflymin}) rectangle ({\absnoeudB},{\pflymax}) ;
        \clip ({\absnoeudA},{\pflymin}) -- plot[smooth] coordinates {\xintthecoords\xintfloatexpr seq((x,#3),x=\absnoeudA..[\pflstepcurve]..\absnoeudB,\absnoeudB)\relax} -- ({\absnoeudB},{\pflymin}) -- cycle ;
        \clip ({\absnoeudA},{\pflymax}) -- \pfldomtikznamesplineb -- ({\absnoeudB},{\pflymax}) -- cycle ;
        \filldraw[integraletikzstyle,integralebordtikzstyle,#2] ({\absnoeudA},{\pflymin}) rectangle ({\absnoeudB},{\pflymax}) ;
      \end{scope}
      \path[draw=none,pflcourbe,name path=tmpintbornea] ({\absnoeudA},{\pflymin})--({\absnoeudA},{\pflymax}) ;
      \path[name intersections={of=tmpintbornea and #4,name=ZZZA}] ;
      \path[draw=none,pflcourbe,name path=tmpintborneb] ({\absnoeudB},{\pflymin})--({\absnoeudB},{\pflymax}) ;
      \path[name intersections={of=tmpintborneb and #4,name=ZZZB}] ;
      \draw[\pfldomtikzcolorbord,pfltrait] ({\absnoeudA},{\xintfloateval{subs(#3,x=\absnoeudA)}})-- (ZZZA-1) ;
      \draw[\pfldomtikzcolorbord,pfltrait] ({\absnoeudB},{\xintfloateval{subs(#3,x=\absnoeudB)}})-- (ZZZB-1) ;
    }%
    {}%
  \IfStrEq{\pfldomtikztype}{spl/fct}%avec #3=spline + #4=fct
    {%
      \begin{scope}
        \clip ({\absnoeudA},{\pflymin}) rectangle ({\absnoeudB},{\pflymax}) ;
        \clip ({\absnoeudA},{\pflymax}) -- plot[smooth] coordinates {\xintthecoords\xintfloatexpr seq((x,#4),x=\absnoeudA..[\pflstepcurve]..\absnoeudB,\absnoeudB)\relax} -- ({\absnoeudB},{\pflymax}) -- cycle ;
        \clip ({\absnoeudA},{\pflymin}) -- \pfldomtikznamespline -- ({\absnoeudB},{\pflymin}) -- cycle ;
        \filldraw[integraletikzstyle,integralebordtikzstyle,#2] ({\absnoeudA},{\pflymin}) rectangle ({\absnoeudB},{\pflymax}) ;
      \end{scope}
      \path[draw=none,pflcourbe,name path=tmpintbornea] ({\absnoeudA},{\pflymin})--({\absnoeudA},{\pflymax}) ;
      \path[name intersections={of=tmpintbornea and #3,name=ZZZA}] ;
      \path[draw=none,pflcourbe,name path=tmpintborneb] ({\absnoeudB},{\pflymin})--({\absnoeudB},{\pflymax}) ;
      \path[name intersections={of=tmpintborneb and #3,name=ZZZB}] ;
      \draw[\pfldomtikzcolorbord,pfltrait] ({\absnoeudA},{\xintfloateval{subs(#4,x=\absnoeudA)}})-- (ZZZA-1) ;
      \draw[\pfldomtikzcolorbord,pfltrait] ({\absnoeudB},{\xintfloateval{subs(#4,x=\absnoeudB)}})-- (ZZZB-1) ;
    }%
    {}%
  \IfStrEq{\pfldomtikztype}{fct/itp}%avec #3=formule + #4=liste interpo
    {%
      \begin{scope}
        \clip ({\absnoeudA},{\pflymin}) rectangle ({\absnoeudB},{\pflymax}) ;
        \clip ({\absnoeudA},{\pflymin}) -- plot[smooth] coordinates {\xintthecoords\xintfloatexpr seq((x,#3),x=\absnoeudA..[\pflstepcurve]..\absnoeudB,\absnoeudB)\relax} -- ({\absnoeudB},{\pflymin}) -- cycle ;
        \clip ({\absnoeudA},{\pflymax}) -- plot [smooth,tension={\useKV[GraphiqueTikzIntegr]{TensionB}}] coordinates {#4} -- ({\absnoeudB},{\pflymax}) ;
        \filldraw[integraletikzstyle,integralebordtikzstyle,#2] ({\absnoeudA},{\pflymin}) rectangle ({\absnoeudB},{\pflymax}) ;
      \end{scope}
      \path[draw=none,pflcourbe,name path=tmpintbornea] ({\absnoeudA},{\pflymin})--({\absnoeudA},{\pflymax}) ;
      \path[draw=none,pflcourbe,name path=tmpintborneb] ({\absnoeudB},{\pflymin})--({\absnoeudB},{\pflymax}) ;
      \path[name intersections={of=tmpintbornea and \pfldomtikznameinterpob,name=ZZZAA}] ;
      \path[name intersections={of=tmpintborneb and \pfldomtikznameinterpob,name=ZZZAB}] ;
      \draw[\pfldomtikzcolorbord,pfltrait] ({\absnoeudA},{\xintfloateval{subs(#3,x=\absnoeudA)}})-- (ZZZAA-1) ;
      \draw[\pfldomtikzcolorbord,pfltrait] ({\absnoeudB},{\xintfloateval{subs(#3,x=\absnoeudB)}})-- (ZZZAB-1) ;
    }%
    {}%
  \IfStrEq{\pfldomtikztype}{itp/fct}%
    {%
      \begin{scope}
        \clip ({\absnoeudA},{\pflymin}) rectangle ({\absnoeudB},{\pflymax}) ;
        \clip ({\absnoeudA},{\pflymax}) -- plot[smooth] coordinates {\xintthecoords\xintfloatexpr seq((x,#4),x=\absnoeudA..[\pflstepcurve]..\absnoeudB,\absnoeudB)\relax} -- ({\absnoeudB},{\pflymax}) -- cycle ;
        \clip ({\absnoeudA},{\pflymin}) -- plot [smooth,tension={\useKV[GraphiqueTikzIntegr]{Tension}}] coordinates {#3} -- ({\absnoeudB},{\pflymin}) ;
        \filldraw[integraletikzstyle,integralebordtikzstyle,#2] ({\absnoeudA},{\pflymin}) rectangle ({\absnoeudB},{\pflymax}) ;
      \end{scope}
      \path[draw=none,pflcourbe,name path=tmpintbornea] ({\absnoeudA},{\pflymin})--({\absnoeudA},{\pflymax}) ;
      \path[draw=none,pflcourbe,name path=tmpintborneb] ({\absnoeudB},{\pflymin})--({\absnoeudB},{\pflymax}) ;
      \path[name intersections={of=tmpintbornea and \pfldomtikznameinterpo,name=ZZZAA}] ;
      \path[name intersections={of=tmpintborneb and \pfldomtikznameinterpo,name=ZZZAB}] ;
      \draw[\pfldomtikzcolorbord,pfltrait] ({\absnoeudA},{\xintfloateval{subs(#4,x=\absnoeudA)}})-- (ZZZAA-1) ;
      \draw[\pfldomtikzcolorbord,pfltrait] ({\absnoeudB},{\xintfloateval{subs(#4,x=\absnoeudB)}})-- (ZZZAB-1) ;
    }%
    {}%
  \IfStrEq{\pfldomtikztype}{itp/spl}%
    {%
      \begin{scope}
        \clip ({\absnoeudA},{\pflymin}) rectangle ({\absnoeudB},{\pflymax}) ;
        \clip ({\absnoeudA},{\pflymin}) -- plot [smooth,tension={\useKV[GraphiqueTikzIntegr]{Tension}}] coordinates {#3} -- ({\absnoeudB},{\pflymin}) ;
        \clip ({\absnoeudA},{\pflymax}) -- \pfldomtikznamesplineb -- ({\absnoeudB},{\pflymax}) -- cycle ;
        \filldraw[integraletikzstyle,integralebordtikzstyle,#2] ({\absnoeudA},{\pflymin}) rectangle ({\absnoeudB},{\pflymax}) ;
      \end{scope}
      \path[draw=none,pflcourbe,name path=tmpintbornea] ({\absnoeudA},{\pflymin})--({\absnoeudA},{\pflymax}) ;%borne inf
      \path[draw=none,pflcourbe,name path=tmpintborneb] ({\absnoeudB},{\pflymin})--({\absnoeudB},{\pflymax}) ;%borne sup
      \path[name intersections={of=tmpintbornea and \pfldomtikznameinterpo,name=YYYKAA}] ;
      \path[name intersections={of=tmpintborneb and \pfldomtikznameinterpo,name=YYYKBB}] ;
      \path[name intersections={of=tmpintbornea and #4,name=ZZZKAA}] ;
      \path[name intersections={of=tmpintborneb and #4,name=ZZZKBB}] ;
      \draw[\pfldomtikzcolorbord,pfltrait] (YYYKAA-1)-- (ZZZKAA-1) ;
      \draw[\pfldomtikzcolorbord,pfltrait] (YYYKBB-1)-- (ZZZKBB-1) ;
    }%
    {}%
  \IfStrEq{\pfldomtikztype}{spl/itp}%
    {%
      \begin{scope}
        \clip ({\absnoeudA},{\pflymin}) rectangle ({\absnoeudB},{\pflymax}) ;
        \clip ({\absnoeudA},{\pflymax}) -- plot [smooth,tension={\useKV[GraphiqueTikzIntegr]{TensionB}}] coordinates {#4} -- ({\absnoeudB},{\pflymax}) ;
        \clip ({\absnoeudA},{\pflymin}) -- \pfldomtikznamespline -- ({\absnoeudB},{\pflymin}) -- cycle ;
        \filldraw[integraletikzstyle,integralebordtikzstyle,#2] ({\absnoeudA},{\pflymin}) rectangle ({\absnoeudB},{\pflymax}) ;
      \end{scope}
      \path[draw=none,pflcourbe,name path=tmpintbornea] ({\absnoeudA},{\pflymin})--({\absnoeudA},{\pflymax}) ;%borne inf
      \path[draw=none,pflcourbe,name path=tmpintborneb] ({\absnoeudB},{\pflymin})--({\absnoeudB},{\pflymax}) ;%borne sup
      \path[name intersections={of=tmpintbornea and \pfldomtikznameinterpob,name=YYYKAA}] ;
      \path[name intersections={of=tmpintborneb and \pfldomtikznameinterpob,name=YYYKBB}] ;
      \path[name intersections={of=tmpintbornea and #3,name=ZZZKAA}] ;
      \path[name intersections={of=tmpintborneb and #3,name=ZZZKBB}] ;
      \draw[\pfldomtikzcolorbord,pfltrait] (YYYKAA-1)-- (ZZZKAA-1) ;
      \draw[\pfldomtikzcolorbord,pfltrait] (YYYKBB-1)-- (ZZZKBB-1) ;
    }%
    {}%
}

%====POINTS
\NewDocumentCommand\PlacerPoints{ s O{black} D<>{\normalfont\normalsize} m }{%
  \IfBooleanTF{#1}%
    {%
      \foreach \Point in {#4}{%
        \filldraw[#2] \Point circle[pflpointc] ;
      }
    }%
    {%
      \foreach \Point/\Pos/\Label in {#4}{%
        \filldraw[#2] \Point circle[pflpointc] node[pflnoeud,\Pos,font=#3] {\Label} ;
      }
    }%
}

%====STATS À 2 VARIABLES
\defKV[GraphiqueTikzRegLin]{%
  Arrondis=\def\pflarrondisreglin{#1},
  Nom=\def\pflnamereglin{#1},
  NomPara=\def\pflnameregquad{#1},
  Debut=\def\pflreglinmin{#1},
  Fin=\def\pflreglinmax{#1},%
  TaillePts=\def\pflreglintaillepts{#1}
}
\setKVdefault[GraphiqueTikzRegLin]{
  CouleurNuage=black,
  CouleurDroite=black,
  CouleurPara=black,
  Arrondis={},
  Debut={\pflxmin},
  Fin={\pflxmax},
  Nom=reglin,%
  NomPara=quadreg,%
  TracerDroite=false,%
  TracerParabole=false,%
  Style=o,%
  TaillePts=1.75pt
}

\NewDocumentCommand\TracerNuageSuite{ s O{} m }{%
  \useKVdefault[GraphiqueTikzRegLin]%
  \setKV[GraphiqueTikzRegLin]{#2}% on paramètres les nouvelles clés et on les simplifie
  \xintdeffloatfunc tmpu(n) := #3 ;
  \IfStrEq{\pflnamereglin}{reglin}{\def\pflnamereglin{u}}{}%
  \IfBooleanTF{#1}%
    {%
      \foreach \n in {\pflreglinmin,...,\pflreglinmax}{%
        \MarquerPts*%
          [Style={\useKV[GraphiqueTikzRegLin]{Style}},Couleur={\useKV[GraphiqueTikzRegLin]{CouleurNuage}},Taillec=\pflreglintaillepts,Taillex=\pflreglintaillepts,Tailleo=\pflreglintaillepts]%
          {(\n,\xintfloateval{tmpu(\n)})}%
      }
    }%
    {%
      \foreach \n in {\pflreglinmin,...,\pflreglinmax}{%
        \MarquerPts%
          [Style={\useKV[GraphiqueTikzRegLin]{Style}},Couleur={\useKV[GraphiqueTikzRegLin]{CouleurNuage}},Taillec=\pflreglintaillepts,Taillex=\pflreglintaillepts,Tailleo=\pflreglintaillepts]%
          {(\n,\xintfloateval{tmpu(\n)})/{$\pflnamereglin_{\n}$}/below}%
      }
    }%
}

\NewDocumentCommand\TracerNuage{ O{} D<>{d} m m }{%
  \useKVdefault[GraphiqueTikzRegLin]%
  \setKV[GraphiqueTikzRegLin]{#1}% on paramètres les nouvelles clés et on les simplifie
  %listes des données
  \def\xliste{#3}
  \def\yliste{#4}
  \setsepchar{,}%
  \readlist*\LX{\xliste}
  \readlist*\LY{\yliste}
  %taille des listes
  \def\LNB{\inteval{\LXlen}}
  %nuage
  \foreach \i in {1,...,\LXlen}{%
    \itemtomacro\LX[\i]\tmpmavalx%
    \itemtomacro\LY[\i]\tmpmavaly%
    \MarquerPts*[Style={\useKV[GraphiqueTikzRegLin]{Style}},Couleur={\useKV[GraphiqueTikzRegLin]{CouleurNuage}}]{(\tmpmavalx,\tmpmavaly)}%
  }
  %droite de régression
  \ifboolKV[GraphiqueTikzRegLin]{TracerDroite}%
    {%
      %somme des LX et des LY OK
      \xdef\LXSomme{0}
      \xdef\LYSomme{0}
      \foreach \i in {1,2,...,\LNB}{
        \xdef\LXSomme{\xintfloateval{\LXSomme+\LX[\i]}}
      }
      \foreach \i in {1,2,...,\LNB}{
        \xdef\LYSomme{\xintfloateval{\LYSomme+\LY[\i]}}
      }
      %moyenne des LX et des LY OK
      \xdef\LXmoy{\xintfloateval{\LXSomme/\LNB}}
      \xdef\LYmoy{\xintfloateval{\LYSomme/\LNB}}
      %variance des LX et des LY OK
      \xdef\LXvar{0}
      \foreach \i in {1,2,...,\LNB}{
        \xdef\LXvar{\xintfloateval{\LXvar+(\LX[\i]-\LXmoy)*(\LX[\i]-\LXmoy)}}
      }
      \xdef\LXvar{\xintfloateval{\LXvar/\LNB}}
      \xdef\LYvar{0}
      \foreach \i in {1,2,...,\LNB}{
        \xdef\LYvar{\xintfloateval{\LYvar+(\LY[\i]-\LYmoy)*(\LY[\i]-\LYmoy)}}
      }
      \xdef\LYvar{\xintfloateval{\LYvar/\LNB}}
      %covariance des XY OK
      \xdef\LXYvar{0}
      \foreach \i in {1,2,...,\LNB}{
        \xdef\LXYvar{\xintfloateval{\LXYvar+(\LX[\i]-\LXmoy)*(\LY[\i]-\LYmoy)}}
      }
      \xdef\LXYvar{\xintfloateval{\LXYvar/\LNB}}
      %COEFFS OK
      \IfStrEq{\pflarrondisreglin}{}%
      {%
        \xdef\tmpcoeffreglina{\xintfloateval{\LXYvar/\LXvar}}
        \xdef\tmpcoeffreglinb{\xintfloateval{\LYmoy-\tmpcoeffreglina*\LXmoy}}
      }%
      {%
        \IfSubStr{\pflarrondisreglin}{/}%
        {%
          \StrCut{\pflarrondisreglin}{/}{\pflarrondisreglina}{\pflarrondisreglinb}
        }%
        {%
          \xdef\pflarrondisreglina{\pflarrondisreglin}\xdef\pflarrondisreglinb{\pflarrondisreglin}
        }%
        \xdef\tmpcoeffreglina{\xintfloateval{round(\LXYvar/\LXvar,\pflarrondisreglina)}}
        \xdef\tmpcoeffreglinb{\xintfloateval{round(\LYmoy-\tmpcoeffreglina*\LXmoy,\pflarrondisreglinb)}}
      }%
      \xintdeffloatfunc #2(x) := (\tmpcoeffreglina)*x+(\tmpcoeffreglinb) ;
      %tracé
      \begin{scope}
        \clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax});
        \draw[pflcourbe,{\useKV[GraphiqueTikzRegLin]{CouleurDroite}},name path global=\pflnamereglin,samples=2,domain=\pflreglinmin:\pflreglinmax] plot (\x,{\tmpcoeffreglina*\x+\tmpcoeffreglinb}) ;
      \end{scope}
    }%
    {}%
  \ifboolKV[GraphiqueTikzRegLin]{TracerParabole}%
    {%
      %somme importantes
      \xdef\LXSomme{0}%
      \xdef\LXCSomme{0}%
      \xdef\LYSomme{0}%
      \xdef\LXXSomme{0}%
      \xdef\LXYSomme{0}%
      \xdef\LXXCSomme{0}%
      \xdef\LXCXCSomme{0}%
      \xdef\LXCYSomme{0}%
      %calculs
      \foreach \i in {1,2,...,\LNB}{%
        \xdef\LXSomme{\xintfloateval{\LXSomme+\LX[\i]}}%
        \xdef\LXCSomme{\xintfloateval{\LXCSomme+(\LX[\i])^2}}%
      }%
      \foreach \i in {1,2,...,\LNB}{%
        \xdef\LYSomme{\xintfloateval{\LYSomme+\LY[\i]}}%
      }%
      \xdef\LXmoy{\xintfloateval{\LXSomme/\LNB}}%
      \xdef\LYmoy{\xintfloateval{\LYSomme/\LNB}}%
      \xdef\LXCmoy{\xintfloateval{\LXCSomme/\LNB}}%
      %calculs suites
      \foreach \i in {1,2,...,\LNB}{%
        \xdef\LXXSomme{\xintfloateval{\LXXSomme+(\LX[\i]-\LXmoy)^2}}%
        \xdef\LXYSomme{\xintfloateval{\LXYSomme+(\LX[\i]-\LXmoy)*(\LY[\i]-\LYmoy)}}%
        \xdef\LXXCSomme{\xintfloateval{\LXXCSomme+(\LX[\i]-\LXmoy)*((\LX[\i])*(\LX[\i])-\LXCmoy)}}%
        \xdef\LXCXCSomme{\xintfloateval{\LXCXCSomme+((\LX[\i])^2-\LXCmoy)^2}}%
        \xdef\LXCYSomme{\xintfloateval{\LXCYSomme+((\LX[\i])^2-\LXCmoy)*(\LY[\i]-\LYmoy)}}%
      }%
      %COEFFS OK
      \IfStrEq{\pflarrondisreglin}{}%
        {%
          \xdef\tmpcoeffregquadb{\xintfloateval{(\LXYSomme*\LXCXCSomme-\LXCYSomme*\LXXCSomme)/(\LXXSomme*\LXCXCSomme-(\LXXCSomme)^2)}}
          \xdef\tmpcoeffregquada{\xintfloateval{(\LXCYSomme*\LXXSomme-\LXYSomme*\LXXCSomme)/(\LXXSomme*\LXCXCSomme-(\LXXCSomme)^2)}}
          \xdef\tmpcoeffregquadc{\xintfloateval{\LYmoy-\tmpcoeffregquadb*\LXmoy-\tmpcoeffregquada*\LXCmoy}}
        }%
        {%
          \xdef\tmpcoeffregquadb{\xintfloateval{round((\LXYSomme*\LXCXCSomme-\LXCYSomme*\LXXCSomme)/(\LXXSomme*\LXCXCSomme-(\LXXCSomme)^2),\pflarrondisreglin)}}
          \xdef\tmpcoeffregquada{\xintfloateval{round((\LXCYSomme*\LXXSomme-\LXYSomme*\LXXCSomme)/(\LXXSomme*\LXCXCSomme-(\LXXCSomme)^2),\pflarrondisreglin)}}
          \xdef\tmpcoeffregquadc{\xintfloateval{round(\LYmoy-\tmpcoeffregquadb*\LXmoy-\tmpcoeffregquada*\LXCmoy,\pflarrondisreglin)}}
        }%
      \xintdeffloatfunc #2(x) := (\tmpcoeffregquada)*x^2+(\tmpcoeffregquadb)*x+\tmpcoeffregquadc ;
      %tracé
      \begin{scope}
        \clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax});
        \draw[pflcourbe,{\useKV[GraphiqueTikzRegLin]{CouleurPara}},name path global=\pflnameregquad,samples=250,domain=\pflreglinmin:\pflreglinmax] plot (\x,{\tmpcoeffregquada*(\x)^2+\tmpcoeffregquadb*\x+\tmpcoeffregquadc}) ;
      \end{scope}
    }%
    {}%
}

\if@loadxintreg
%régressions alternatives
\NewDocumentCommand\TracerAjustement{ O{} D<>{cbajust} m D<>{} m m }{%
  %1=options de tracés
  %2=nom courbe
  %3=type
  %4=arrondis
  %5=liste X
  %6=liste Y
  \IfStrEq{#3}{lin}%
    {%
      \xintlinreg[round={#4}]{#5}{#6}%
      \DefinirFonction[#1,Trace]<#2>{\linrega*x+\linregb}%
    }%
    {}%
  \IfStrEq{#3}{quad}%
    {%
      \xintquadreg[round={#4}]{#5}{#6}%
      \DefinirFonction[#1,Trace]<#2>{\quadrega*x^2+\quadregb*x+\quadregc}%
    }%
    {}%
  \IfStrEq{#3}{pow}%
    {%
      \xintpowreg[round={#4}]{#5}{#6}%
      \DefinirFonction[#1,Trace]<#2>{\powrega*x^(\powregb)}%
    }%
    {}%
  \IfStrEq{#3}{expab}%
    {%
      \xintexpabreg[round={#4}]{#5}{#6}%
      \DefinirFonction[#1,Trace]<#2>{\expabrega*(\expabregb)^x}%
    }%
    {}%
  \IfStrEq{#3}{hyp}%
    {%
      \xinthypreg[round={#4}]{#5}{#6}%
      \DefinirFonction[#1,Trace]<#2>{\hyprega+(\hypregb)/x}%
    }%
    {}%
  \IfStrEq{#3}{log}%
    {%
      \xintlogreg[round={#4}]{#5}{#6}%
      \DefinirFonction[#1,Trace]<#2>{\logrega+(\logregb)*log(x)}%
    }%
    {}%
  \IfStrEq{#3}{exp}%
    {%
      \xintexpreg[round={#4}]{#5}{#6}%
      \DefinirFonction[#1,Trace]<#2>{exp(\exprega*x+\expregb)}%
    }%
    {}%
  \IfStrEq{#3}{expalt}%
    {%
      \xintexpreg[Alt,round={#4}]{#5}{#6}%
      \DefinirFonction[#1,Trace]<#2>{\expregb*exp(\exprega*x)}%
    }%
    {}%
  \IfStrEq{#3}{cub}%
    {%
      \xintcubreg[round={#4}]{#5}{#6}%
      \DefinirFonction[#1,Trace]<#2>{\cubrega*x^3+\cubregb*x^2+\cubregc*x+\cubregd}%
    }%
    {}%
  \IfSubStr{#3}{expoff}%
    {%
      \StrBehind{#3}{=}[\expoffset]%
      \xintexpoffreg[round={#4},offset=\expoffset]{#5}{#6}%
      \DefinirFonction[#1,Trace]<#2>{\expoffset+\expregoffb*exp(\expregoffa*x)}%
    }%
    {}%
}
\fi

%===IMAGES & ANTÉCÉDENTS
\defKV[GraphiqueTikzImg]{
  Couleurs=\def\pflimgcolors{#1},%
  Nom=\def\pflantecednoms{#1}%
}

\setKVdefault[GraphiqueTikzImg]{
  Couleurs=black,%
  Traits=false,%
  Spline=false,%
  Nom={},%
  Style=o
}

\NewDocumentCommand\DefinirImage{ O{} m m }{%
  \useKVdefault[GraphiqueTikzImg]%
  \setKV[GraphiqueTikzImg]{#1}%
  \ifboolKV[GraphiqueTikzImg]{Spline}%
    {%
      \path[draw=none,pflcourbe,name path=tmpimage] ({#3},{\pflymin})--({#3},{\pflymax}) ;
      \path[name intersections={of=#2 and tmpimage,name=ZZZZ}] ;
      \coordinate (\pflantecednoms) at (ZZZZ-1) ;
    }%
    {%
      \xdef\tmpresimg{\xintfloateval{#2(#3)}}%
      \coordinate (\pflantecednoms) at ({#3},{\tmpresimg}) ;
    }%
}

\NewDocumentCommand\PlacerImages{ O{} m m }{%
  \useKVdefault[GraphiqueTikzImg]%
  \setKV[GraphiqueTikzImg]{#1}%
  \IfSubStr{\pflimgcolors}{/}%
    {%
      \StrCut{\pflimgcolors}{/}{\pflimgcolorpt}{\pflimgcolorline}
    }%
    {%
      \xdef\pflimgcolorpt{\pflimgcolors}\xdef\pflimgcolorline{\pflimgcolors}
    }%
  \ifboolKV[GraphiqueTikzImg]{Spline}%
    {%
      \foreach \i in {#3}{%
        \path[draw=none,pflcourbe,name path=tmpimage] ({\i},{\pflymin})--({\i},{\pflymax}) ;
        \path[name intersections={of=#2 and tmpimage,name=ZZ}] ;
        \ifboolKV[GraphiqueTikzImg]{Traits}%
          {%
            \draw[\pflimgcolorline,pfltraitimg] let \p1 = (ZZ-1) in ({\x1},{\pflOy}) |- ({\pflOx},{\y1}) ;
          }%
          {}%
        \MarquerPts*[Style={\useKV[GraphiqueTikzImg]{Style}},Couleur=\pflimgcolorpt]{(ZZ-1)}
        %\filldraw[\pflimgcolorpt] (ZZ-1) circle[radius=2pt] ;
      }
    }%
    {%
      \foreach \i in {#3}{%
        \xdef\tmpresimg{\xintfloateval{#2(\i)}}%
        \ifboolKV[GraphiqueTikzImg]{Traits}%
          {%
            \draw[\pflimgcolorline,pfltraitimg] ({\i},{\pflOy}) |- ({\pflOx},{\tmpresimg}) ;
          }%
          {}%
        \MarquerPts*[Style={\useKV[GraphiqueTikzImg]{Style}},Couleur=\pflimgcolorpt]{({\i},{\tmpresimg})}
        %\filldraw[\pflimgcolorpt] ({\i},{\tmpresimg}) circle[radius=2pt] ;
      }%
    }%
}

\NewDocumentCommand\PlacerAntecedents{ O{} m m }{%avec le nom de la courbe...
  \useKVdefault[GraphiqueTikzImg]%
  \setKV[GraphiqueTikzImg]{#1}%
  \xdef\pflstepcurve{\xintfloateval{0.1*\pflgrillexs}}
  \IfSubStr{\pflimgcolors}{/}%
  {%
    \StrCut{\pflimgcolors}{/}{\pflimgcolorpt}{\pflimgcolorline}%
  }%
  {%
    \xdef\pflimgcolorpt{\pflimgcolors}\xdef\pflimgcolorline{\pflimgcolors}%
  }%
  \begin{scope}
    \clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax});
    \path[draw=none,pflcourbe,name path=tmpanteced] ({\pflxmin},{#3})--({\pflxmax},{#3}) ;
    \path[name intersections={of=#2 and tmpanteced,name=ZZ,total=\t}] \pgfextra{\xdef\tmptotanteced{\t}};
    \xintifboolexpr{\tmptotanteced == 0}{}%
      {%
        \ifboolKV[GraphiqueTikzImg]{Traits}%
          {%
            \draw[\pflimgcolorline,pfltraitantec] ({\pflxmin},{#3})--({\pflxmax},{#3}) ;
          }%
          {}%
        \foreach \i in {1,...,\tmptotanteced}{%
          \IfStrEq{\pflantecednoms}{}%
            {}%
            {%
              \coordinate (\pflantecednoms-\i) at (ZZ-\i) ;
            }%
          \ifboolKV[GraphiqueTikzImg]{Traits}%
            {%
              \draw[\pflimgcolorline,pfltraitimg] let \p1 = (ZZ-\i) in (ZZ-\i) -- ({\x1},{\pflOy}) ;
            }%
            {}%
          \MarquerPts*[Style={\useKV[GraphiqueTikzImg]{Style}},Couleur=\pflimgcolorpt]{(ZZ-\i)}
          %\filldraw[\pflimgcolorpt] (ZZ-\i) circle[radius=2pt] ;
        }%
      }%
  \end{scope}
}

%===NOMBRE DÉRIVÉ ET TANGENTE (EXPÉRIEMENTAL)
\NewDocumentCommand\CalculerNbDerive{ s m m m }{%*=gauche+nomfct+abspt+h
  \IfBooleanTF{#1}%
    {%
      \xdef\TmpResNbDeriv{\xintfloateval{(#2(#3)-#2(#3-#4))/(#4)}}%
    }%
    {%
      \xdef\TmpResNbDeriv{\xintfloateval{(#2(#3+#4)-#2(#3))/(#4)}}%
    }%
}

\defKV[GraphiqueTikzTgte]{%
  Couleurs=\def\pfltgttikzcolors{#1},%
  DecG=\def\pfltgttikzkl{#1},%
  DecD=\def\pfltgttikzkr{#1},%
  h=\def\pfltgttikzh{#1},%
  Sens=\def\pfltgttikzsens{#1},%
  Delta=\def\tmptgtedelta{#1}
}
\setKVdefault[GraphiqueTikzTgte]{%
  Couleurs=black,%
  DecG=1,%
  DecD=1,%
  AffPoint=false,%
  Spline=false,%
  h=0.1,%
  Sens=gd,%
  Noeud=false,%
  Delta=0.01,%
  Style=o
}

\NewDocumentCommand\TracerTangente{ O{} m m D<>{} }{%
  \restoreKV[GraphiqueTikzTgte]%
  \setKV[GraphiqueTikzTgte]{#1}%
  %en fonction de la gestion de l'abscisse
  \ifboolKV[GraphiqueTikzTgte]{Noeud}%
    {%
      \path #3;
      \pgfgetlastxy{\macrox}{\macroy}%
      \xdef\pfltgttikzx{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
    }%
    {%
      \xdef\pfltgttikzx{#3}%
    }%
  %parties communes
  \IfSubStr{\pfltgttikzcolors}{/}%
    {%
      \StrCut{\pfltgttikzcolors}{/}{\pfltgttikzline}{\pfltgttikzpoint}
    }%
    {%
      \xdef\pfltgttikzline{\pfltgttikzcolors}\xdef\pfltgttikzpoint{\pfltgttikzcolors}
    }%
  \xdef\tmptgtdeb{\xintfloateval{\pfltgttikzx-(\pfltgttikzkl)}}%
  \xdef\tmptgtfin{\xintfloateval{\pfltgttikzx+(\pfltgttikzkr)}}%
  %suivant le type de courbe
  \ifboolKV[GraphiqueTikzTgte]{Spline}%
    {%
        \path[name path=tmpimage] ({\pfltgttikzx},{\pflymin})--({\pfltgttikzx},{\pflymax}) ;
        \path[name intersections={of=#2 and tmpimage,name=TANp}] ;
        \IfStrEq{\pfltgttikzsens}{gd}%
          {%
            \path[name path=L-vline] ({\pfltgttikzx-\tmptgtedelta},{\pflymin}) -- ({\pfltgttikzx-\tmptgtedelta},{\pflymax}) ;
            \path[name path=R-vline] ({\pfltgttikzx+\tmptgtedelta},{\pflymin}) -- ({\pfltgttikzx+\tmptgtedelta},{\pflymax}) ;
            %\coordinate (LXcoor) at ($(TANp-1)+({-\tmptgtedelta},0)$) ;
            %\coordinate (RXcoor) at ($(TANp-1)+({\tmptgtedelta},0)$) ;
          }%
          {}%
        \IfStrEq{\pfltgttikzsens}{g}%
          {%
            \path[name path=L-vline] ({\pfltgttikzx-\tmptgtedelta},{\pflymin}) -- ({\pfltgttikzx-\tmptgtedelta},{\pflymax}) ;
            \path[name path=R-vline] ({\pfltgttikzx},{\pflymin}) -- ({\pfltgttikzx},{\pflymax}) ;
            %\coordinate (LXcoor) at ($(TANp-1)+({-\tmptgtedelta},0)$) ;
            %\coordinate (RXcoor) at (TANp-1) ;
            \def\tmptgtfin{\pfltgttikzx}%
          }%
          {}%
        \IfStrEq{\pfltgttikzsens}{d}%
          {%
            \path[name path=L-vline] ({\pfltgttikzx},{\pflymin}) -- ({\pfltgttikzx},{\pflymax}) ;
            \path[name path=R-vline] ({\pfltgttikzx+\tmptgtedelta},{\pflymin}) -- ({\pfltgttikzx+\tmptgtedelta},{\pflymax}) ;
            \def\tmptgtdeb{\pfltgttikzx}%
          }%
          {}%
        \path[name intersections={of=#2 and L-vline,name=LXcut}] ;
        \path[name intersections={of=#2 and R-vline,name=RXcut}] ;
        \coordinate (tzXproj) at ($(LXcut-1)!(TANp-1)!(RXcut-1)$) ; % projection
        \coordinate (LLpoint) at ($(LXcut-1)+(TANp-1)-(tzXproj)$) ; % move
        \coordinate (RRpoint) at ($(RXcut-1)+(TANp-1)-(tzXproj)$) ; % move
        \path (LLpoint);
        \pgfgetlastxy{\macrox}{\macroy}%
        \xdef\tzTANLLX{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
        \xdef\tzTANLLY{\xintfloateval{(\ConvertirPtToCm{\macroy})/(\pflyunit)}}%
        \path (RRpoint);
        \pgfgetlastxy{\macrox}{\macroy}%
        \xdef\tzTANRRX{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
        \xdef\tzTANRRY{\xintfloateval{(\ConvertirPtToCm{\macroy})/(\pflyunit)}}%
        \def\tztangentLFn{(\tzTANRRY-\tzTANLLY)/(\tzTANRRX-\tzTANLLX)*(\x-\tzTANLLX)+\tzTANLLY}%
        \begin{scope}
          \clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax}) ;
          \draw[pfltrait,\pfltgttikzline,domain=\tmptgtdeb:\tmptgtfin,samples=2,#4] plot (\x,{\tztangentLFn}) ;
        \end{scope}
    }%
    {%
      \IfStrEq{\pfltgttikzsens}{g}%
        {%
          \CalculerNbDerive*{#2}{\pfltgttikzx}{\pfltgttikzh}%
        }%
        {%
          \CalculerNbDerive{#2}{\pfltgttikzx}{\pfltgttikzh}%
        }%
      \begin{scope}
        \clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax}) ;
        \draw[pfltrait,\pfltgttikzline,#4] plot[smooth] coordinates {%
          \xintthecoords\xintfloatexpr
          seq((x,\TmpResNbDeriv*(x-(\pfltgttikzx))+#2(\pfltgttikzx)),x=\tmptgtdeb,\tmptgtfin)
          \relax
        };
      \end{scope}
    }%
  \ifboolKV[GraphiqueTikzTgte]{AffPoint}%
    {%
      \ifboolKV[GraphiqueTikzTgte]{Spline}%
        {%
          \MarquerPts*[Style={\useKV[GraphiqueTikzTgte]{Style}},Couleur=\pfltgttikzpoint]{(TANp-1)}
          %\filldraw[] (TANp-1) circle[pflpointc] ;
        }%
        {%
          \xdef\tmpimgtgt{\xintfloateval{#2(\pfltgttikzx)}}%
          \MarquerPts*[Style={\useKV[GraphiqueTikzTgte]{Style}},Couleur=\pfltgttikzpoint]{({\pfltgttikzx},\tmpimgtgt)}
          %\filldraw[\pfltgttikzpoint] ({\pfltgttikzx},\tmpimgtgt) circle[pflpointc] ;
        }%
    }%
    {}%
}

%====LOI NORMALE
\defKV[GraphiqueTikzGaussienne]{%
  Pas=\def\pflgaussstep{#1},%
  Nom=\def\pflgaussname{#1}
}

\setKVdefault[GraphiqueTikzGaussienne]{%
  Nom=gaussienne,%
  Couleur=black,%
  Trace=false,%
  Pas={},%
  Debut={\pflxmin},%
  Fin={\pflxmax}
}

\NewDocumentCommand\DefinirLoiNormale{ O{} D<>{phi} m m }{%
  %1=options
  %2=mu
  %3=sigma
  \restoreKV[GraphiqueTikzGaussienne]%
  \setKV[GraphiqueTikzGaussienne]{#1}%
  \xintdeffloatfunc #2(x) := 1/((#4)*sqrt(2*pi))*exp(-0.5*((x-(#3))/(#4))^2) ;%
  \IfStrEq{\pflgaussstep}{}%
    {%
      \xdef\pflgaussstep{\xintfloateval{((\useKV[GraphiqueTikzGaussienne]{Fin})-(\useKV[GraphiqueTikzGaussienne]{Debut}))/100}}%
    }%
    {}%
  \begin{scope}
    \clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax});
    \ifboolKV[GraphiqueTikzGaussienne]{Trace}%
      {%
        \path[draw,pflcourbe,{\useKV[GraphiqueTikzGaussienne]{Couleur}},name path global=\pflgaussname] plot[smooth] coordinates {%
          \xintthecoords\xintfloatexpr
          seq((x,#2(x)),x={\useKV[GraphiqueTikzGaussienne]{Debut}}..[\pflgaussstep]..{\useKV[GraphiqueTikzGaussienne]{Fin}},{\useKV[GraphiqueTikzGaussienne]{Fin}})
          \relax
        } ;
      }%
      {%
        \path[draw=none,pflcourbe,name path global=\pflgaussname]  plot[smooth] coordinates {%
          \xintthecoords\xintfloatexpr
          seq((x,#2(x)),x={\useKV[GraphiqueTikzGaussienne]{Debut}}..[\pflgaussstep]..{\useKV[GraphiqueTikzGaussienne]{Fin}},{\useKV[GraphiqueTikzGaussienne]{Fin}})
          \relax
        } ;
      }%
  \end{scope}
}

\NewDocumentCommand\TracerLoiNormale{ O{} m }{%
  %1=options
  %2=mu
  %3=sigma
  \restoreKV[GraphiqueTikzGaussienne]%
  \setKV[GraphiqueTikzGaussienne]{#1}%
  \IfStrEq{\pflgaussstep}{}%
    {%
      \xdef\pflgaussstep{\xintfloateval{((\useKV[GraphiqueTikzGaussienne]{Fin})-(\useKV[GraphiqueTikzGaussienne]{Debut}))/100}}%
    }%
    {}%
  \begin{scope}
    \clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax});
    \draw[pflcourbe,{\useKV[GraphiqueTikzGaussienne]{Couleur}}]  plot[smooth] coordinates {%
      \xintthecoords\xintfloatexpr
      seq((x,#2),x={\useKV[GraphiqueTikzGaussienne]{Debut}}..[\pflgaussstep]..{\useKV[GraphiqueTikzGaussienne]{Fin}},{\useKV[GraphiqueTikzGaussienne]{Fin}})
      \relax
    } ;
  \end{scope}
}

\NewDocumentCommand\DefinirLoiKhiDeux{ O{} D<>{khi} m }{%
  %1=options
  %2=mu
  %3=sigma
  \restoreKV[GraphiqueTikzGaussienne]%
  \setKV[GraphiqueTikzGaussienne]{#1}%
  \xintdeffloatfunc #2(x) := (x<0)?{0}{(1/(2^((#3)/2)*pflgamma((#3)/2)))*x^((#3)/2-1)*exp(-x/2)};
  \IfStrEq{\pflgaussstep}{}%
  {%
    \xdef\pflgaussstep{\xintfloateval{((\useKV[GraphiqueTikzGaussienne]{Fin})-(\useKV[GraphiqueTikzGaussienne]{Debut}))/100}}%
  }%
  {}%
  \begin{scope}
    \clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax});
    \ifboolKV[GraphiqueTikzGaussienne]{Trace}%
      {%
        \path[draw,pflcourbe,{\useKV[GraphiqueTikzGaussienne]{Couleur}},name path global=\pflgaussname] plot[smooth] coordinates {%
          \xintthecoords\xintfloatexpr
          seq((x,#2(x)),x={\useKV[GraphiqueTikzGaussienne]{Debut}}..[\pflgaussstep]..{\useKV[GraphiqueTikzGaussienne]{Fin}},{\useKV[GraphiqueTikzGaussienne]{Fin}})
          \relax
        } ;
      }%
      {%
        \path[draw=none,pflcourbe,name path global=\pflgaussname]  plot[smooth] coordinates {%
          \xintthecoords\xintfloatexpr
          seq((x,#2(x)),x={\useKV[GraphiqueTikzGaussienne]{Debut}}..[\pflgaussstep]..{\useKV[GraphiqueTikzGaussienne]{Fin}},{\useKV[GraphiqueTikzGaussienne]{Fin}})
          \relax
        } ;
      }%
  \end{scope}
}

\NewDocumentCommand\TracerLoiKhiDeux{ O{} m }{%
  %1=options
  %2=mu
  %3=sigma
  \restoreKV[GraphiqueTikzGaussienne]%
  \setKV[GraphiqueTikzGaussienne]{#1}%
  \IfStrEq{\pflgaussstep}{}%
    {%
      \xdef\pflgaussstep{\xintfloateval{((\useKV[GraphiqueTikzGaussienne]{Fin})-(\useKV[GraphiqueTikzGaussienne]{Debut}))/100}}%
    }%
    {}%
  \begin{scope}
    \clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax});
    \draw[pflcourbe,{\useKV[GraphiqueTikzGaussienne]{Couleur}}]  plot[smooth] coordinates {%
      \xintthecoords\xintfloatexpr
      seq((x,#2),x={\useKV[GraphiqueTikzGaussienne]{Debut}}..[\pflgaussstep]..{\useKV[GraphiqueTikzGaussienne]{Fin}},{\useKV[GraphiqueTikzGaussienne]{Fin}})
      \relax
    } ;
  \end{scope}
}

%====DROITE
\defKV[GraphiquetikzDroite]{%
  Nom=\def\pfldroitename{#1},%
  StyleTrace=\def\pfldroitestyle{#1}
}

\setKVdefault[GraphiquetikzDroite]{%
  Pente=false,%
  Couleur=black,%
  Debut={\pflxmin},%
  Fin={\pflxmax},%
  Nom={},%
  StyleTrace={}
}

\NewDocumentCommand\TracerDroite{ O{} m m D<>{} }{%
  \restoreKV[GraphiquetikzDroite]%
  \setKV[GraphiquetikzDroite]{#1}%
  %1er point
  \path #2;%
  \pgfgetlastxy{\macrox}{\macroy}%
  \xdef\pfldtetikzxA{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
  \xdef\pfldtetikzyA{\xintfloateval{(\ConvertirPtToCm{\macroy})/(\pflyunit)}}%
  %2ème point si besoin
  \ifboolKV[GraphiquetikzDroite]{Pente}%
    {%
      \xdef\pfldtepente{\xintfloateval{#3}}%
    }%
    {%
      \path #3;%
      \pgfgetlastxy{\macrox}{\macroy}%
      \xdef\pfldtetikzxB{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
      \xdef\pfldtetikzyB{\xintfloateval{(\ConvertirPtToCm{\macroy})/(\pflyunit)}}%
      \xdef\pfldtepente{\xintfloateval{(\pfldtetikzyB-\pfldtetikzyA)/(\pfldtetikzxB-\pfldtetikzxA)}}%
    }%
  \begin{scope}
    \clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax}) ;
    \xintifboolexpr{\pfldtetikzxA == \pfldtetikzxB}%
      {%
        \IfEq{\pfldroitename}{}%
          {%
            \draw[pfltrait,\pfldroitestyle,{\useKV[GraphiquetikzDroite]{Couleur}},#4] (\pfldtetikzxA,\pflymin) -- (\pfldtetikzxA,\pflymax) ;
          }%
          {%
            \draw[pfltrait,\pfldroitestyle,{\useKV[GraphiquetikzDroite]{Couleur}},#4,name path global=\pfldroitename] (\pfldtetikzxA,\pflymin) -- (\pfldtetikzxA,\pflymax) ;
          }%
      }%
      {%
        \IfEq{\pfldroitename}{}%
          {%
            \draw[pfltrait,\pfldroitestyle,{\useKV[GraphiquetikzDroite]{Couleur}},domain={\useKV[GraphiquetikzDroite]{Debut}}:{\useKV[GraphiquetikzDroite]{Fin}},samples=2,#4] plot (\x,{\pfldtepente*(\x-\pfldtetikzxA)+\pfldtetikzyA}) ;
          }%
          {%
            \draw[pfltrait,\pfldroitestyle,{\useKV[GraphiquetikzDroite]{Couleur}},domain={\useKV[GraphiquetikzDroite]{Debut}}:{\useKV[GraphiquetikzDroite]{Fin}},samples=2,name path global=\pfldroitename,#4] plot (\x,{\pfldtepente*(\x-\pfldtetikzxA)+\pfldtetikzyA}) ;
          }%
      }%
  \end{scope}
}

%====ASYMPTOTE
\NewDocumentCommand\TracerAsymptote{ O{} m D<>{} }{%
  \restoreKV[GraphiquetikzDroite]%
  \setKV[GraphiquetikzDroite]{#1}%
  %tracé
  \draw[pfltrait,\pfldroitestyle,{\useKV[GraphiquetikzDroite]{Couleur}},#3] ({#2},{\pflymin})--({#2},{\pflymax}) ;
}


%====MINMAX
\defKV[GraphiqueTikzMinMax]{%
  Pas=\def\pflminmaxstep{#1},%
  Methode=\def\pflminmaxmethode{#1},%
  Coeffs=\def\pflminmaxcoeffs{#1}
}
\setKVdefault[GraphiqueTikzMinMax]{%
  Debut={\pflxmin},%
  Fin={\pflxmax},%
  Pas={},%
  Tension=0.5,%
  Methode=fonction,%
  Coeffs=3
}

\NewDocumentCommand\TrouverMaximum{ O{} m O{c-max} }{%
  %1=clés
  %2=paramètres en fonction de [Methode]
  \restoreKV[GraphiqueTikzMinMax]%
  \setKV[GraphiqueTikzMinMax]{#1}%
  \IfStrEq{\pflstepcurve}{}%
    {%
      \xdef\pflminmaxstep{\xintfloateval{((\useKV[GraphiqueTikzMinMax]{Fin})-(\useKV[GraphiqueTikzMinMax]{Debut}))/100}}%
    }%
    {}%
  \begin{scope}[bezier bounding box,local bounding box=bbtmpmax]
    \IfStrEq{\pflminmaxmethode}{fonction}%
      {%
        \path[draw=none,name path=curvetmpmax] plot[smooth] coordinates {%
          \xintthecoords\xintfloatexpr
          seq((x,#2(x)),x={\useKV[GraphiqueTikzMinMax]{Debut}}..[\pflstepcurve]..{\useKV[GraphiqueTikzMinMax]{Fin}},{\useKV[GraphiqueTikzMinMax]{Fin}})
          \relax
        };
      }%
      {}%
    \IfStrEq{\pflminmaxmethode}{interpo}%
      {%
        \path[draw=none,name path=curvetmpmax] plot[smooth,tension={\useKV[GraphiqueTikzMinMax]{Tension}}] coordinates {#2};
      }%
      {}%
    \IfStrEq{\pflminmaxmethode}{spline}%
      {%
        \GenererSpline{#2}{\pflminmaxcoeffs}[\tmpsplineminmax]%
        \path[draw=none,name path=curvetmpmax] \tmpsplineminmax ;
      }%
      {}%
    %retour
    \path[name path=tmpmax] ([yshift=-0.25\pgflinewidth]bbtmpmax.north east) -- ([yshift=-0.25\pgflinewidth]bbtmpmax.north west) ;
    \path[name intersections={of=curvetmpmax and tmpmax,name=#3}] ;
    \coordinate (#3) at ($0.5*(#3-1)+0.5*(#3-2)+(0,0.25\pgflinewidth)$) ;
  \end{scope}
}

\NewDocumentCommand\TrouverMinimum{ O{} m O{c-min} }{%
  %1=clés
  %2=paramètres en fonction de [Methode]
  \restoreKV[GraphiqueTikzMinMax]%
  \setKV[GraphiqueTikzMinMax]{#1}%
  \IfStrEq{\pflstepcurve}{}%
    {%
      \xdef\pflminmaxstep{\xintfloateval{((\useKV[GraphiqueTikzMinMax]{Fin})-(\useKV[GraphiqueTikzMinMax]{Debut}))/100}}%
    }%
    {}%
  \begin{scope}[bezier bounding box,local bounding box=bbtmpmin]
    \IfStrEq{\pflminmaxmethode}{fonction}%
      {%
        \path[draw=none,name path=curvetmpmin] plot[smooth] coordinates {%
          \xintthecoords\xintfloatexpr
          seq((x,#2(x)),x={\useKV[GraphiqueTikzMinMax]{Debut}}..[\pflstepcurve]..{\useKV[GraphiqueTikzMinMax]{Fin}},{\useKV[GraphiqueTikzMinMax]{Fin}})
          \relax
        };
      }%
      {}%
    \IfStrEq{\pflminmaxmethode}{interpo}%
      {%
        \path[draw=none,name path=curvetmpmin] plot[smooth,tension={\useKV[GraphiqueTikzMinMax]{Tension}}] coordinates {#2};
      }%
      {}%
    \IfStrEq{\pflminmaxmethode}{spline}%
      {%
        \GenererSpline{#2}{\pflminmaxcoeffs}[\tmpsplineminmax]%
        \path[draw=none,name path=curvetmpmin] \tmpsplineminmax ;
      }%
      {}%
    %retour
    \path[name path=tmpmin] ([yshift=0.25\pgflinewidth]bbtmpmin.south east) -- ([yshift=0.25\pgflinewidth]bbtmpmin.south west) ;
    \path[name intersections={of=curvetmpmin and tmpmin,name=#3}] ;
    \coordinate (#3) at ($0.5*(#3-1)+0.5*(#3-2)+(0,-0.25\pgflinewidth)$) ;
  \end{scope}
}

%====TEXTES
\defKV[GraphiqueTikzNode]{%
  Couleur=\def\pflnodecol{#1},%
  Police=\def\pflnodefonte{#1},%
  Position=\def\pfnodepos{#1}
}
\setKVdefault[GraphiqueTikzNode]{%
  Couleur=black,%
  Police={\normalfont\normalsize},%
  Position={}
}
\NewDocumentCommand\PlacerTexte{ O{} m m }{%
  \restoreKV[GraphiqueTikzNode]%
  \setKV[GraphiqueTikzNode]{#1}%
  \draw #2 node[pflnoeud,font=\pflnodefonte,text=\pflnodecol,\pfnodepos] {#3} ;
}

\NewDocumentCommand\TracerEllipse{ O{} m m m }{%
  \restoreKV[GraphiqueTikzCourbe]%
  \setKV[GraphiqueTikzCourbe]{#1}%
  %booléens spécifiques pour Axes de symétries, foyers, sommets
  \path #2 ;
  \pgfgetlastxy{\macrox}{\macroy}%
  \xdef\pflxcentreellipse{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
  \xdef\pflycentreellipse{\xintfloateval{(\ConvertirPtToCm{\macroy})/(\pflyunit)}}%
  %on parse à courbe param !
  \TracerCourbeParam[#1]{\pflxcentreellipse+(#3)*cos(t)}{\pflycentreellipse+(#4)*sin(t)}%
  %pour les foyers
  \xdef\tmptkzcellipse{\xintfloateval{sqrt(max(#3,#4)^2-min(#3,#4)^2)}}%
}

\NewDocumentCommand\TracerParabole{ O{} m m }{%
  \restoreKV[GraphiqueTikzCourbe]%
  \setKV[GraphiqueTikzCourbe]{#1}%
  \path #2 ;
  \pgfgetlastxy{\macrox}{\macroy}%
  \xdef\pflxsommetparabole{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
  \xdef\pflysommetparabole{\xintfloateval{(\ConvertirPtToCm{\macroy})/(\pflyunit)}}%
  % Sens=V (défaut) ou Sens=H
  \IfStrEq{\pflsensparab}{H}{%
    % axe horizontal : x = h + t²/(4p), y = k + t
    % t joue le rôle de y-k, on borne sur Ymin/Ymax
    \TracerCourbeParam[#1,%
    Debut=\xintfloateval{\pflymin-\pflysommetparabole},%
    Fin=\xintfloateval{\pflymax-\pflysommetparabole}]%
    {\pflxsommetparabole+(t)^2/(4*(#3))}{\pflysommetparabole+(t)}%
  }{%
    % axe vertical : x = h + t, y = k + t²/(4p)
    % t joue le rôle de x-h, on borne sur Xmin/Xmax
    \TracerCourbeParam[#1,%
    Debut=\xintfloateval{\pflxmin-\pflxsommetparabole},%
    Fin=\xintfloateval{\pflxmax-\pflxsommetparabole}]%
    {\pflxsommetparabole+(t)}{\pflysommetparabole+(t)^2/(4*(#3))}%
  }%
}

\NewDocumentCommand\TracerHyperbole{ O{} m m m }{%
  \restoreKV[GraphiqueTikzCourbe]%
  \setKV[GraphiqueTikzCourbe]{#1}%
  \path #2 ;
  \pgfgetlastxy{\macrox}{\macroy}%
  \xdef\pflxcentrehyperbole{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
  \xdef\pflycentrehyperbole{\xintfloateval{(\ConvertirPtToCm{\macroy})/(\pflyunit)}}%
  \xdef\pflnamecurveA{\pflnamecurve{}A}%
  \xdef\pflnamecurveB{\pflnamecurve{}B}%
  \IfStrEq{\pflsensparab}{H}%
  {%
    % axe horizontal : x = h ± a*cosh(t), y = k + b*sinh(t)
    \TracerCourbeParam[#1,Debut=-5,Fin=5,Nom=\pflnamecurveA]%
      {\pflxcentrehyperbole+(#3)*((exp(t)+exp(-t))/2)}%
      {\pflycentrehyperbole+(#4)*((exp(t)-exp(-t))/2)}%
    \TracerCourbeParam[#1,Debut=-5,Fin=5,Nom=\pflnamecurveB]%
      {\pflxcentrehyperbole-(#3)*((exp(t)+exp(-t))/2)}%
      {\pflycentrehyperbole+(#4)*((exp(t)-exp(-t))/2)}%
  }%
  {%
    % axe vertical : y = k ± b*cosh(t), x = h + a*sinh(t)
    \TracerCourbeParam[#1,Debut=-5,Fin=5,Nom=\pflnamecurveA]%
    {\pflxcentrehyperbole+(#3)*((exp(t)-exp(-t))/2)}%
    {\pflycentrehyperbole+(#4)*((exp(t)+exp(-t))/2)}%
    \TracerCourbeParam[#1,Debut=-5,Fin=5,Nom=\pflnamecurveB]%
    {\pflxcentrehyperbole+(#3)*((exp(t)-exp(-t))/2)}%
    {\pflycentrehyperbole-(#4)*((exp(t)+exp(-t))/2)}%
  }%
}

\defKV[GraphiqueTikzConique]{%
  Sens=\def\pflsensparab{#1}
}

\setKVdefault[GraphiqueTikzConique]{%
  CouleurPoints=black,%
  CouleurDroites=black,% couleur spécifique pour les éléments
  AffCentre=false,%
  AffFoyers=false,%
  AffSommets=false,%
  AffAxes=false,%
  AffDirectrice=false,% parabole
  AffAsymptotes=false,% hyperbole,%
  AffTout=false,%
  Sens=V
}

\NewDocumentCommand\AfficherElementsEllipse{ O{} m m m m }{%
  % #1=clés #2=nom #3=centre #4=a #5=b
  \restoreKV[GraphiqueTikzConique]%
  \setKV[GraphiqueTikzConique]{#1}%
  \path #3 ;
  \pgfgetlastxy{\macrox}{\macroy}%
  \xdef\pflxcentre{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
  \xdef\pflycentre{\xintfloateval{(\ConvertirPtToCm{\macroy})/(\pflyunit)}}%
  \xdef\pflcellipse{\xintfloateval{sqrt(abs((#4)^2-(#5)^2))}}%
  %booléen spécifique
  \ifboolKV[GraphiqueTikzConique]{AffTout}%
    {%
      \setKV[GraphiqueTikzConique]{AffCentre=true,AffFoyers=true,AffSommets=true,AffAxes=true}%
    }%
    {}%
  % nœuds centre
  \coordinate (#2-C) at (\pflxcentre,\pflycentre) ;
  % on détermine si grand axe horizontal ou vertical
  \xintifboolexpr{ #4 > #5 }%
    {%
      \coordinate (#2-F1) at (\xintfloateval{\pflxcentre+\pflcellipse},\pflycentre) ;%
      \coordinate (#2-F2) at (\xintfloateval{\pflxcentre-\pflcellipse},\pflycentre) ;%
    }%
    {%
      \coordinate (#2-F1) at (\pflxcentre,\xintfloateval{\pflycentre+\pflcellipse}) ;%
      \coordinate (#2-F2) at (\pflxcentre,\xintfloateval{\pflycentre-\pflcellipse}) ;%
    }%
  % nœuds sommets
  \coordinate (#2-S1) at (\xintfloateval{\pflxcentre+(#4)},\pflycentre) ;%
  \coordinate (#2-S2) at (\xintfloateval{\pflxcentre-(#4)},\pflycentre) ;%
  \coordinate (#2-S3) at (\pflxcentre,\xintfloateval{\pflycentre+(#5)}) ;%
  \coordinate (#2-S4) at (\pflxcentre,\xintfloateval{\pflycentre-(#5)}) ;%
  % affichages
  \ifboolKV[GraphiqueTikzConique]{AffAxes}%
    {%
      \draw[{\useKV[GraphiqueTikzConique]{CouleurDroites}},pfltraitvoisinageasympt] 
        (\xintfloateval{\pflxcentre-1.1*(#4)},\pflycentre) --
        (\xintfloateval{\pflxcentre+1.1*(#4)},\pflycentre) ;%
      \draw[{\useKV[GraphiqueTikzConique]{CouleurDroites}},pfltraitvoisinageasympt] 
        (\pflxcentre,\xintfloateval{\pflycentre-1.1*(#5)}) --
        (\pflxcentre,\xintfloateval{\pflycentre+1.1*(#5)}) ;%
    }%
    {}%
  \ifboolKV[GraphiqueTikzConique]{AffCentre}%
    {%
      \MarquerPts*[Couleur={\useKV[GraphiqueTikzConique]{CouleurPoints}}]{(#2-C)}
    }{}%
  \ifboolKV[GraphiqueTikzConique]{AffFoyers}%
    {%
      \MarquerPts*[Couleur={\useKV[GraphiqueTikzConique]{CouleurPoints}}]{(#2-F1),(#2-F2)}%
    }%
    {}%
  \ifboolKV[GraphiqueTikzConique]{AffSommets}%
    {%
      \MarquerPts*[Couleur={\useKV[GraphiqueTikzConique]{CouleurPoints}}]{(#2-S1),(#2-S2),(#2-S3),(#2-S4)}%
    }%
    {}%
}

\NewDocumentCommand\AfficherElementsParabole{ O{} m m m }{%
  % #1=clés #2=nom #3=sommet #4=p
  \restoreKV[GraphiqueTikzConique]%
  \setKV[GraphiqueTikzConique]{#1}%
  \path #3 ;
  \pgfgetlastxy{\macrox}{\macroy}%
  \xdef\pflxsommet{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
  \xdef\pflysommet{\xintfloateval{(\ConvertirPtToCm{\macroy})/(\pflyunit)}}%
  % AffTout
  \ifboolKV[GraphiqueTikzConique]{AffTout}%
  {\setKV[GraphiqueTikzConique]{AffFoyers=true,AffSommets=true,AffAxes=true,AffDirectrice=true}}%
  {}%
  % nœud sommet
  \coordinate (#2-S) at (\pflxsommet,\pflysommet) ;%
  % foyer et directrice selon sens
  \IfStrEq{\pflsensparab}{H}{%
    % axe horizontal : foyer à (h+p, k), directrice x = h-p
    \coordinate (#2-F) at (\xintfloateval{\pflxsommet+(#4)},\pflysommet) ;%
    \coordinate (#2-D1) at (\xintfloateval{\pflxsommet-(#4)},\pflymin) ;%
    \coordinate (#2-D2) at (\xintfloateval{\pflxsommet-(#4)},\pflymax) ;%
    \coordinate (#2-A1) at (\pflxmin,\pflysommet) ;%
    \coordinate (#2-A2) at (\pflxmax,\pflysommet) ;%
  }%
  {%
    % axe vertical : foyer à (h, k+p), directrice y = k-p
    \coordinate (#2-F) at (\pflxsommet,\xintfloateval{\pflysommet+(#4)}) ;%
    \coordinate (#2-D1) at (\pflxmin,\xintfloateval{\pflysommet-(#4)}) ;%
    \coordinate (#2-D2) at (\pflxmax,\xintfloateval{\pflysommet-(#4)}) ;%
    \coordinate (#2-A1) at (\pflxsommet,\pflymin) ;%
    \coordinate (#2-A2) at (\pflxsommet,\pflymax) ;%
  }%
  % axe de symétrie
  \ifboolKV[GraphiqueTikzConique]{AffAxes}%
  {%
    \draw[{\useKV[GraphiqueTikzConique]{CouleurDroites}},pfltraitvoisinageasympt]
    (#2-A1) -- (#2-A2) ;%
  }{}%
  % directrice
  \ifboolKV[GraphiqueTikzConique]{AffDirectrice}%
  {%
    \draw[{\useKV[GraphiqueTikzConique]{CouleurDroites}},pfltraitvoisinageasympt]
    (#2-D1) -- (#2-D2) ;%
  }{}%
  % foyer
  \ifboolKV[GraphiqueTikzConique]{AffFoyers}%
  {%
    \MarquerPts*[Couleur={\useKV[GraphiqueTikzConique]{CouleurPoints}}]{(#2-F)}%
  }{}%
  % sommet
  \ifboolKV[GraphiqueTikzConique]{AffSommets}%
  {%
    \MarquerPts*[Couleur={\useKV[GraphiqueTikzConique]{CouleurPoints}}]{(#2-S)}%
  }{}%
}

\NewDocumentCommand\AfficherElementsHyperbole{ O{} m m m m }{%
  % #1=clés #2=nom #3=centre #4=a #5=b
  \restoreKV[GraphiqueTikzConique]%
  \setKV[GraphiqueTikzConique]{#1}%
  \path #3 ;
  \pgfgetlastxy{\macrox}{\macroy}%
  \xdef\pflxcentre{\xintfloateval{(\ConvertirPtToCm{\macrox})/(\pflxunit)}}%
  \xdef\pflycentre{\xintfloateval{(\ConvertirPtToCm{\macroy})/(\pflyunit)}}%
  % c = sqrt(a²+b²) pour l'hyperbole !
  \xdef\pflchyperbole{\xintfloateval{sqrt((#4)^2+(#5)^2)}}%
  % AffTout
  \ifboolKV[GraphiqueTikzConique]{AffTout}%
  {\setKV[GraphiqueTikzConique]{AffCentre=true,AffFoyers=true,AffSommets=true,AffAsymptotes=true}}%
  {}%
  % nœud centre
  \coordinate (#2-C) at (\pflxcentre,\pflycentre) ;%
  % foyers et sommets selon sens
  \IfStrEq{\pflsensparab}{V}%
  {%
    % axe vertical
    \coordinate (#2-F1) at (\pflxcentre,\xintfloateval{\pflycentre+\pflchyperbole}) ;%
    \coordinate (#2-F2) at (\pflxcentre,\xintfloateval{\pflycentre-\pflchyperbole}) ;%
    \coordinate (#2-S1) at (\pflxcentre,\xintfloateval{\pflycentre+(#5)}) ;%
    \coordinate (#2-S2) at (\pflxcentre,\xintfloateval{\pflycentre-(#5)}) ;%
  }%
  {%
    % axe horizontal
    \coordinate (#2-F1) at (\xintfloateval{\pflxcentre+\pflchyperbole},\pflycentre) ;%
    \coordinate (#2-F2) at (\xintfloateval{\pflxcentre-\pflchyperbole},\pflycentre) ;%
    \coordinate (#2-S1) at (\xintfloateval{\pflxcentre+(#4)},\pflycentre) ;%
    \coordinate (#2-S2) at (\xintfloateval{\pflxcentre-(#4)},\pflycentre) ;%
  }%
  % affichages
  \ifboolKV[GraphiqueTikzConique]{AffAsymptotes}%
  {%
    \begin{scope}
    \clip (\pflxmin,\pflymin) rectangle (\pflxmax,\pflymax) ;
    % asymptotes : pentes ±b/a (H) ou ±a/b (V)
    \IfStrEq{\pflsensparab}{V}%
    {%
      \draw[{\useKV[GraphiqueTikzConique]{CouleurDroites}},pfltraitvoisinageasympt]
        (\pflxmin, \xintfloateval{\pflycentre+(#4)/(#5)*(\pflxmin-\pflxcentre)}) --
        (\pflxmax, \xintfloateval{\pflycentre+(#4)/(#5)*(\pflxmax-\pflxcentre)}) ;
    \draw[{\useKV[GraphiqueTikzConique]{CouleurDroites}},pfltraitvoisinageasympt]
      (\pflxmin, \xintfloateval{\pflycentre-(#4)/(#5)*(\pflxmin-\pflxcentre)}) --
      (\pflxmax, \xintfloateval{\pflycentre-(#4)/(#5)*(\pflxmax-\pflxcentre)}) ;
    }%
    {%
      \draw[{\useKV[GraphiqueTikzConique]{CouleurDroites}},pfltraitvoisinageasympt]
        (\pflxmin, \xintfloateval{\pflycentre+(#5)/(#4)*(\pflxmin-\pflxcentre)}) --
        (\pflxmax, \xintfloateval{\pflycentre+(#5)/(#4)*(\pflxmax-\pflxcentre)}) ;
      \draw[{\useKV[GraphiqueTikzConique]{CouleurDroites}},pfltraitvoisinageasympt]
        (\pflxmin, \xintfloateval{\pflycentre-(#5)/(#4)*(\pflxmin-\pflxcentre)}) --
        (\pflxmax, \xintfloateval{\pflycentre-(#5)/(#4)*(\pflxmax-\pflxcentre)}) ;
    }%
    \end{scope}%
  }{}%
  \ifboolKV[GraphiqueTikzConique]{AffCentre}%
    {\MarquerPts*[Couleur={\useKV[GraphiqueTikzConique]{CouleurPoints}}]{(#2-C)}}{}%
  \ifboolKV[GraphiqueTikzConique]{AffFoyers}%
    {\MarquerPts*[Couleur={\useKV[GraphiqueTikzConique]{CouleurPoints}}]{(#2-F1),(#2-F2)}}{}%
  \ifboolKV[GraphiqueTikzConique]{AffSommets}%
    {\MarquerPts*[Couleur={\useKV[GraphiqueTikzConique]{CouleurPoints}}]{(#2-S1),(#2-S2)}}{}%
}

%====ECC
\defKV[tkzgECC]{%
  Couleur=\def\tkzecc@coul@graph{#1},%
  CouleursParams=\def\tkzecc@coul@params{#1}
}

\setKVdefault[tkzgECC]{%
  Couleur=black,%
  AffParams=true,%
  CouleursParams={black},%
  TraitsComplets=true
}

\NewDocumentCommand\TracerCourbeECC{ O{} m m }{%
  \restoreKV[tkzgECC]%
  \setKV[tkzgECC]{#1}%
  \IfSubStr{\tkzecc@coul@params}{/}%
    {%
      \StrCut{\tkzecc@coul@params}{/}{\tkzecc@coul@quart}{\tkzecc@coul@med}%
    }%
    {%
      \def\tkzecc@coul@quart{\tkzecc@coul@params}\def\tkzecc@coul@med{\tkzecc@coul@params}%
    }%
  \setsepchar{,}%
  \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\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)}}%
      }
      {}%
  }%
  %partie graphique
  \draw[pflcourbeecc,\tkzecc@coul@graph] \DonneesListeECC ;
  \xintFor* ##1 in {\xintSeq{1}{\DataECClen}}\do{%
    \filldraw[\tkzecc@coul@graph] (\DataClass[##1],\DataECC[##1]) circle[pflpointnuage] ;
  }%
  \ifboolKV[tkzgECC]{AffParams}%
      {%
        %médiane
        \ifboolKV[tkzgECC]{TraitsComplets}%
          {%
            \draw[pfltraitsparamecc,\tkzecc@coul@med] (\pflxmin,{0.50*\DonneesEffMax})--(\pflxmax,{0.50*\DonneesEffMax});
            \draw[pfltraitsparamecc,\tkzecc@coul@quart] (\pflxmin,{0.25*\DonneesEffMax})--++({\pflxmax-\pflxmin},0);
            \draw[pfltraitsparamecc,\tkzecc@coul@quart] (\pflxmin,{0.75*\DonneesEffMax})--++({\pflxmax-\pflxmin},0);
          }%
          {%
            \draw[pfltraitsparamecc,\tkzecc@coul@med] (\pflxmin,{0.50*\DonneesEffMax})--(\ValMed,{0.50*\DonneesEffMax});
            \draw[pfltraitsparamecc,\tkzecc@coul@quart] (\pflxmin,{0.25*\DonneesEffMax})--++({\ValPremQuartile-\pflxmin},0);
            \draw[pfltraitsparamecc,\tkzecc@coul@quart] (\pflxmin,{0.75*\DonneesEffMax})--++({\ValTroisQuartile-\pflxmin},0);
          }%
        \draw[pfltraitsparamecc,\tkzecc@coul@med] (\ValMed,{0.5*\DonneesEffMax})--(\ValMed,0) ; \draw[\tkzecc@coul@med,thick,fill=white] (\ValMed,{0.5*\DonneesEffMax}) circle[pflpointnuage] ;
        \draw[pfltraitsparamecc,\tkzecc@coul@quart] (\ValPremQuartile,{0.25*\DonneesEffMax})--(\ValPremQuartile,\pflymin) ; \draw[\tkzecc@coul@quart,thick,fill=white] (\ValPremQuartile,{0.25*\DonneesEffMax}) circle[pflpointnuage] ;
        \draw[pfltraitsparamecc,\tkzecc@coul@quart] (\ValTroisQuartile,{0.75*\DonneesEffMax})--(\ValTroisQuartile,\pflymin) ; \draw[\tkzecc@coul@quart,thick,fill=white] (\ValTroisQuartile,{0.75*\DonneesEffMax}) circle[pflpointnuage] ;
      }%
      {}%
}

%====PTS DISCONTINUITÉ
\defKV[tkzptdiscont]{%
  Couleur=\def\pfldiscontcouleur{#1},%
  Pos=\def\pfldiscontpos{#1},%
  Echelle=\def\pfldiscontechelle{#1},%
  Type=\def\pfldisconttype{#1}
}

\setKVdefault[tkzptdiscont]{%
  Couleur=black,%
  Pos=D,%
  Echelle=1,%
  Type=par
}

\NewDocumentCommand\AfficherPtsDiscont{ O{} m }{%
  \restoreKV[tkzptdiscont]
  \setKV[tkzptdiscont]{#1}%
  \setsepchar[.]{§./}%
  \readlist*\SPLlisteDiscont{#2}%
  \def\SPLlisteDiscontNb{\SPLlisteDiscontlen}%
  \foreach \i in {1,...,\SPLlisteDiscontNb}{%
    \begin{scope}[shift={(\SPLlisteDiscont[\i,1],\SPLlisteDiscont[\i,2])},rotate={atan \SPLlisteDiscont[\i,3]},scale=\pfldiscontechelle]
      \IfStrEq{\pfldisconttype}{rond}%
        {%
          \draw[pflcourbediscont,fill=white,draw=\pfldiscontcouleur] (0,0) circle[radius=3pt] ;
        }{}%
      \IfStrEq{\pfldiscontpos}{D}%
        {%
          \IfStrEq{\pfldisconttype}{par}%
            {%
              \draw[pflcourbediscont,\pfldiscontcouleur] (0,0) to[out=90,in=170] (4pt,5pt) ;
              \draw[pflcourbediscont,\pfldiscontcouleur] (0,0) to[out=-90,in=-170] (4pt,-5pt) ;
            }{}%
          \IfStrEq{\pfldisconttype}{demirond}%
            {%
              \draw[pflcourbediscont,\pfldiscontcouleur] (0,0) to[out=90,in=180] (3pt,3pt) ;
              \draw[pflcourbediscont,\pfldiscontcouleur] (0,0) to[out=-90,in=180] (3pt,-3pt) ;
            }{}%
          \IfStrEq{\pfldisconttype}{cro}%
            {%
              \draw[pflcourbediscont,\pfldiscontcouleur] (0,0) |- (4pt,5pt) ;
              \draw[pflcourbediscont,\pfldiscontcouleur] (0,0) |- (4pt,-5pt) ;
            }{}%
        }%
        {%
          \IfStrEq{\pfldisconttype}{par}%
            {%
              \draw[pflcourbediscont,\pfldiscontcouleur] (0,0) to[out=90,in=-10] (-4pt,5pt) ;
              \draw[pflcourbediscont,\pfldiscontcouleur] (0,0) to[out=-90,in=10] (-4pt,-5pt) ;
            }{}%
          \IfStrEq{\pfldisconttype}{demirond}%
            {%
              \draw[pflcourbediscont,\pfldiscontcouleur] (0,0) to[out=90,in=0] (-3pt,3pt) ;
              \draw[pflcourbediscont,\pfldiscontcouleur] (0,0) to[out=-90,in=0] (-3pt,-3pt) ;
            }{}%
          \IfStrEq{\pfldisconttype}{cro}%
            {%
              \draw[pflcourbediscont,\pfldiscontcouleur] (0,0) |- (-4pt,5pt) ;
              \draw[pflcourbediscont,\pfldiscontcouleur] (0,0) |- (-4pt,-5pt) ;
            }{}%
        }%
    \end{scope}
  }%
}

%====TOILE RÉCURRENCE (OK avec courbe + spline !!)
\defKV[tkzwebrecurr]{%
  Couleur=\def\pflrecurcolor{#1},%
  Nom=\def\pflrecurnom{#1},%
  No=\def\pflrecurno{#1},%
  Nb=\def\pflrecurnb{#1},%
  Uno=\def\pflrecuruno{#1},
  TailleLabel=\def\pflrecurlabelsize{#1},%
  PosLabel=\def\pflrecurlabelpos{#1}
}

\setKVdefault[tkzwebrecurr]{%
  Couleur=black,%
  Spline=false,%
  No=0,%
  Nom=u,%
  Nb=5,%
  AffTermes=false,%
  AffPointilles=true,%
  TailleLabel=\small,%
  PosLabel=below
}

\NewDocumentCommand\TracerToileRecurrence{ O{} m }{
  %<clés> + fonction/courbe
  \useKVdefault[tkzwebrecurr]%
  \setKV[tkzwebrecurr]{#1}% on paramètres les nouvelles clés et on les simplifie
  \ifboolKV[tkzwebrecurr]{Spline}%
    {%
      \foreach \i [remember=\i as \x (initially \pflrecuruno)] in {1,...,\pflrecurnb}{%
        %\xdef\y{\xintfloateval{#2(\x)}}%
        \path[draw=none,pflcourbe,name path=tmprecur] ({\x},{\pflymin})--({\x},{\pflymax}) ;
        \path[name intersections={of=#2 and tmprecur,name=ZZZZ}] ;
        %\coordinate (\pflrecurnoms) at (ZZZZ-1) ;
        \GetYcoord{(ZZZZ-1)}[\y]
        %test de la position courbe / bissectrice ?
        \ifnum \i=1
          \newdimen \X
          \newdimen \Y
          \X = \x pt
          \Y = \y pt
          \ifdim \Y < \X
            \draw[pfltraitrec,\pflrecurcolor] (\x,\y)--(\y,\y) ;
          \else
            \draw[pfltraitrec,\pflrecurcolor] (\x,\x)--(\x,\y)--(\y,\y) ;
          \fi
        \else
          \draw[pfltraitrec,\pflrecurcolor] (\x,\x)--(\x,\y)--(\y,\y) ;
        \fi
        \ifboolKV[tkzwebrecurr]{AffPointilles}%
          {%
            \def\indice{\fpeval{\i+\pflrecurno-1}}%
            \ifboolKV[tkzwebrecurr]{AffTermes}%
              {%
                \draw[pfltraitrecpointill,\pflrecurcolor] (\x,\y)--(\x,\pflxmin) node[\pflrecurlabelpos,font=\pflrecurlabelsize]{$\pflrecurnom_{\indice}$};%
              }%
              {%
                \draw[pfltraitrecpointill,\pflrecurcolor] (\x,\y)--(\x,\pflxmin) ;%
              }%
          }%
          {}
        \def\i{\y}%
      }%
    }%
    {%
      \foreach \i [remember=\i as \x (initially \pflrecuruno)] in {1,...,\pflrecurnb}{%
        \xdef\y{\xintfloateval{#2(\x)}}%
        %test de la position courbe / bissectrice ?
        \ifnum \i=1
          \newdimen \X
          \newdimen \Y
          \X = \x pt
          \Y = \y pt
          \ifdim \Y < \X
            \draw[pfltraitrec,\pflrecurcolor] (\x,\y)--(\y,\y) ;
          \else
            \draw[pfltraitrec,\pflrecurcolor] (\x,\x)--(\x,\y)--(\y,\y) ;
          \fi
        \else
          \draw[pfltraitrec,\pflrecurcolor] (\x,\x)--(\x,\y)--(\y,\y) ;
        \fi
        \ifboolKV[tkzwebrecurr]{AffPointilles}%
          {%
            \def\indice{\fpeval{\i+\pflrecurno-1}}%
            \ifboolKV[tkzwebrecurr]{AffTermes}%
              {%
                \draw[pfltraitrecpointill,\pflrecurcolor] (\x,\y)--(\x,\pflxmin) node[\pflrecurlabelpos,font=\pflrecurlabelsize]{$\pflrecurnom_{\indice}$};%
              }%
              {%
                \draw[pfltraitrecpointill,\pflrecurcolor] (\x,\y)--(\x,\pflxmin) ;%
              }%
          }%
          {}
        \def\i{\xintfloateval{\y}}%
      }%
    }%
}

%====linear inequality [fr]
\defKV[GraphiquetikzInegLin]{%
  Opacite=\def\pflineglinopac{#1},%
  Nom=\def\pflineglinname{#1},%
  Style=\def\pflineglintikzstyle{#1},%
  Hachures=\def\pflineglintikzhatch{#1}
}

\setKVdefault[GraphiquetikzInegLin]{%
  Opacite=0.25,
  Couleur=black,%
  Style=hachures,
  Hachures={north west lines}
}

\NewDocumentCommand\InegaliteLineaire{O{}D<>{f}mm}{%
  \restoreKV[GraphiquetikzInegLin]%
  \setKV[GraphiquetikzInegLin]{#1}%
  %style for filling... ?
  \IfStrEq{\pflineglintikzstyle}{hachures}%
    {%
      \tikzset{dominegallintikzstyle/.style={draw=none,pattern=\pflineglintikzhatch,pattern color={\useKV[GraphiquetikzInegLin]{Couleur}},line join=bevel}}
    }%
    {}%
  \IfStrEq{\pflineglintikzstyle}{remplissage}%
    {%
      \tikzset{dominegallintikzstyle/.style={draw=none,fill={\useKV[GraphiquetikzInegLin]{Couleur}},fill opacity=\pflineglinopac,line join=bevel}}
    }%
    {}%
  %dummy equation
  \xintdeffloatfunc pfldummy(x,y) := #3;
  %coeffc
  \xdef\coeffc{\xintfloateval{pfldummy(0,0)}}%
  %coeffa
  \xdef\coeffa{\xintfloateval{pfldummy(1,0)-pfldummy(0,0)}}%
  %coeffb
  \xdef\coeffb{\xintfloateval{pfldummy(0,1)-pfldummy(0,0)}}%
  %particular part
  \xintifboolexpr{ \coeffb == 0 }%vertical
    {%
      \begin{scope}
        \clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax}) ;
        \xintifboolexpr{ \coeffa > 0 }%
          {%
            \IfBeginWith{#4}{>}%
              {%
                \draw[pfltrait,dominegallintikzstyle] ({-(\coeffc)/(\coeffa)},{\pflymin}) rectangle ({\pflxmax},{\pflymax}) ;
              }%
              {%
                \draw[pfltrait,dominegallintikzstyle] ({-(\coeffc)/(\coeffa)},{\pflymin}) rectangle ({\pflxmin},{\pflymax}) ;
              }%
          }%
          {%
            \IfBeginWith{#4}{>}%
              {%
                \draw[pfltrait,dominegallintikzstyle] ({-(\coeffc)/(\coeffa)},{\pflymin}) rectangle ({\pflxmin},{\pflymax}) ;
              }%
              {%
                \draw[pfltrait,dominegallintikzstyle] ({-(\coeffc)/(\coeffa)},{\pflymin}) rectangle ({\pflxmax},{\pflymax}) ;
              }%
          }%
        \draw[pfltrait,{\useKV[GraphiquetikzInegLin]{Couleur}}] ({-(\coeffc)/(\coeffa)},{\pflymin}) -- ({-(\coeffc)/(\coeffa)},{\pflymax}) ;
      \end{scope}
    }%
    {% b!=0 ()
      \xdef\tmpvalzzyxmin{\xintfloateval{(-\coeffc-\coeffa*(\pflxmin))/(\coeffb)}}%
      \xdef\tmpvalzzyxmax{\xintfloateval{(-\coeffc-\coeffa*(\pflxmax))/(\coeffb)}}%
      \begin{scope}
        \clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax}) ;
        %---
          \xintifboolexpr{ \coeffb > 0 }%
            {%
              \IfBeginWith{#4}{>}%
                {%
                  \draw[pfltrait,dominegallintikzstyle] ({\pflxmin},{\tmpvalzzyxmin}) |- ({\pflxmax},{\tmpvalzzyxmax}) ;
                  \xintifboolexpr{\tmpvalzzyxmax < \pflymax}%
                    {%
                      \filldraw[pfltrait,dominegallintikzstyle] ({\pflxmin},{\pflxmax}) rectangle ({\pflxmax},{\tmpvalzzyxmax}) ;
                    }%
                    {}%
                }%
                {%
                  \draw[pfltrait,dominegallintikzstyle] ({\pflxmin},{\tmpvalzzyxmin}) -| ({\pflxmax},{\tmpvalzzyxmax}) ;
                  \xintifboolexpr{\tmpvalzzyxmin > \pflymin}%
                    {%
                      \filldraw[pfltrait,dominegallintikzstyle] ({\pflxmax},{\pflymin}) rectangle ({\pflxmin},{\tmpvalzzyxmin}) ;
                    }%
                    {}%
                }%
            }%
            {%
              \IfBeginWith{#4}{>}%
                {%
                  \draw[pfltrait,dominegallintikzstyle] ({\pflxmin},{\tmpvalzzyxmin}) |- ({\pflxmax},{\tmpvalzzyxmax}) ;
                  \xintifboolexpr{\tmpvalzzyxmax > \pflymin}%
                    {%
                      \filldraw[pfltrait,dominegallintikzstyle] ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\tmpvalzzyxmax}) ;
                    }%
                    {}%
                }%
                {%
                  \draw[pfltrait,dominegallintikzstyle] ({\pflxmin},{\tmpvalzzyxmin}) -| ({\pflxmax},{\tmpvalzzyxmax}) ;
                  \xintifboolexpr{\tmpvalzzyxmin < \pflymax}%
                    {%
                      \filldraw[pfltrait,dominegallintikzstyle] ({\pflxmin},{\tmpvalzzyxmin}) rectangle ({\pflxmax},{\pflymax}) ;
                    }%
                    {}%
                }%
            }%
        %---
        \draw[pfltrait,{\useKV[GraphiquetikzInegLin]{Couleur}}] ({\pflymin},{(-\coeffc-\coeffa*(\pflxmin))/(\coeffb)}) -- ({\pflymax},{(-\coeffc-\coeffa*(\pflxmax))/(\coeffb)}) ;
      \end{scope}
    }%
  
}

%====TRANSFORMATION f(x-a)+b (formule, spline, interpo)
\defKV[GraphiqueTikzTransfo]{%
  Nom=\def\pflnametransfo{#1},%
  StyleTrace=\def\pflstyletransfo{#1},%
  Pas=\def\pflsteptransfo{#1},%
  Coeffs=\def\pflcoeffstransfo{#1},%
  Tension=\def\pfltensiontransfo{#1}
}

\setKVdefault[GraphiqueTikzTransfo]{%
  Nom={},%
  Couleur=black,%
  Debut={\pflxmin},%
  Fin={\pflxmax},%
  Pas={},%
  Clip=true,%
  Spline=false,%
  Interpo=false,%
  Alt=false,%
  Coeffs=3,%
  Tension=0.5,%
  StyleTrace={}%
}

\NewDocumentCommand\TracerTransformee{ O{} m m m }{%
  %#1 = clés
  %#2 = objet : nom_fct (formule xint) OU liste spline OU liste interpo
  %#3 = a  (décalage horizontal : on trace f(x-a)+b)
  %#4 = b  (décalage vertical)
  \restoreKV[GraphiqueTikzTransfo]%
  \setKV[GraphiqueTikzTransfo]{#1}%
  %---
  \ifboolKV[GraphiqueTikzTransfo]{Spline}%
  {%
    %---cas SPLINE : transformation géométrique des points de contrôle---
    \tkzg@transfo@spline{#2}{#3}{#4}%
    % bifurcation [Alt]
    \ifboolKV[GraphiqueTikzTransfo]{Alt}%
    {%
      \DefinirCourbeSpline%
        [Alt,Trace,%
        Couleur={\useKV[GraphiqueTikzTransfo]{Couleur}},%
        Nom=\pflnametransfo,%
        StyleTrace=\pflstyletransfo,%
        Coeffs=\pflcoeffstransfo]%
        {\TRFlistedecaleespline}%
    }%
    {%
      \DefinirCourbeSpline%
        [Trace,%
        Couleur={\useKV[GraphiqueTikzTransfo]{Couleur}},%
        Nom=\pflnametransfo,%
        StyleTrace=\pflstyletransfo,%
        Coeffs=\pflcoeffstransfo]%
        {\TRFlistedecaleespline}%
    }%
  }%
  {%
    \ifboolKV[GraphiqueTikzTransfo]{Interpo}%
    {%
      %---cas INTERPO : décalage des points (xi+a, yi+b)---
      \tkzg@transfo@interpo{#2}{#3}{#4}%
      \DefinirCourbeInterpo%
        [Trace,%
        Couleur={\useKV[GraphiqueTikzTransfo]{Couleur}},%
        Nom=\pflnametransfo,%
        StyleTrace=\pflstyletransfo,%
        Tension=\pfltensiontransfo]%
        {\TRFlistedecaleeinterpo}%
    }%
    {%
      %---cas FORMULE xint : g(x) = f(x-a)+b---
      \IfStrEq{\pflsteptransfo}{}%
      {%
        \xdef\pflsteptransfo{\xintfloateval{%
            ((\useKV[GraphiqueTikzTransfo]{Fin})-%
            (\useKV[GraphiqueTikzTransfo]{Debut}))/100}}%
      }%
      {}%
      \xintdeffloatfunc pfltransfo(x) := #2(x-(#3))+(#4) ;%
      \ifboolKV[GraphiqueTikzTransfo]{Clip}%
      {\begin{scope}%
          \clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax}) ;}%
        {}%
        \IfEq{\pflnametransfo}{}%
        {%
          \draw[pflcourbe,\pflstyletransfo,%
          {\useKV[GraphiqueTikzTransfo]{Couleur}}]
          plot[smooth] coordinates {%
            \xintthecoords\xintfloatexpr
            seq((x, pfltransfo(x)),
            x=\useKV[GraphiqueTikzTransfo]{Debut}%
            ..[\pflsteptransfo]..%
            \useKV[GraphiqueTikzTransfo]{Fin},%
            \useKV[GraphiqueTikzTransfo]{Fin})
            \relax
          } ;%
        }%
        {%
          \path[draw,pflcourbe,\pflstyletransfo,%
          {\useKV[GraphiqueTikzTransfo]{Couleur}},%
          name path global=\pflnametransfo]
          plot[smooth] coordinates {%
            \xintthecoords\xintfloatexpr
            seq((x, pfltransfo(x)),
            x=\useKV[GraphiqueTikzTransfo]{Debut}%
            ..[\pflsteptransfo]..%
            \useKV[GraphiqueTikzTransfo]{Fin},%
            \useKV[GraphiqueTikzTransfo]{Fin})
            \relax
          } ;%
        }%
        \ifboolKV[GraphiqueTikzTransfo]{Clip}{\end{scope}}{}%
    }%
  }%
}

\defKV[GraphiqueTikzReflexion]{%
  Axe=\def\pflaxereflexion{#1},%
  Nom=\def\pflnamereflexion{#1},%
  StyleTrace=\def\pflstylereflexion{#1},%
  Pas=\def\pflstepreflexion{#1},%
  Coeffs=\def\pflcoeffsreflexion{#1},%
  Tension=\def\pfltensiontransfo{#1}
}

\setKVdefault[GraphiqueTikzReflexion]{%
  Axe=x,%
  Nom={},%
  Couleur=black,%
  Debut={\pflxmin},%
  Fin={\pflxmax},%
  Pas={},%
  Clip=true,%
  Spline=false,%
  Interpo=false,%
  Alt=false,%
  Coeffs=3,%
  Tension=0.5,%
  StyleTrace={}%
}

\NewDocumentCommand\TracerReflexion{ O{} m }{%
  %#1 = clés
  %#2 = objet : nom_fct (formule xint) OU liste spline OU liste interpo
  \restoreKV[GraphiqueTikzReflexion]%
  \setKV[GraphiqueTikzReflexion]{#1}%
  %---
  \ifboolKV[GraphiqueTikzReflexion]{Spline}%
  {%
    %---cas SPLINE---
    \IfStrEq{\pflaxereflexion}{yx}%
    {%
      %---Axe=yx spline : symétrie via scope matriciel---
      % La matrice (0,1,1,0) échange x et y = symétrie par rapport à y=x
      % Requiert des unités égales en x et y pour être visuellement correcte (test à faire ou pas ?)
      \xintifboolexpr{abs(\xintfloateval{\pflyunit/\pflxunit} - 1) < 0.001}%
      {}%
      {%
        \PackageWarning{tkz-grapheur}{Axe=yx+Spline : unites x et y differentes, rendu visuellement incorrect}%
      }%
      % #2 = liste spline originale, on génère le chemin dans \RFXcheminspline
      \ifboolKV[GraphiqueTikzReflexion]{Alt}%
      {\GenererSpline*{#2}{\pflcoeffsreflexion}[\RFXcheminspline]}%
      {\GenererSpline{#2}{\pflcoeffsreflexion}[\RFXcheminspline]}%
      \begin{scope}[cm={0,1,1,0,(0,0)}]%
        \IfEq{\pflnamereflexion}{}%
        {%
          \draw[pflcourbe,\pflstylereflexion,{\useKV[GraphiqueTikzReflexion]{Couleur}}] \RFXcheminspline ;%
        }%
        {%
          \path[draw,pflcourbe,\pflstylereflexion,{\useKV[GraphiqueTikzReflexion]{Couleur}},name path global=\pflnamereflexion] \RFXcheminspline ;%
        }%
      \end{scope}%
    }%
    {%
      \tkzg@reflexion@spline{#2}{\pflaxereflexion}%
      \ifboolKV[GraphiqueTikzReflexion]{Alt}%
      {%
        \DefinirCourbeSpline%
          [Alt,Trace,%
          Couleur={\useKV[GraphiqueTikzReflexion]{Couleur}},%
          Nom=\pflnamereflexion,%
          StyleTrace=\pflstylereflexion,%
          Coeffs=\pflcoeffsreflexion]%
          {\RFXlistedecaleespline}%
      }%
      {%
        \DefinirCourbeSpline%
          [Trace,%
          Couleur={\useKV[GraphiqueTikzReflexion]{Couleur}},%
          Nom=\pflnamereflexion,%
          StyleTrace=\pflstylereflexion,%
          Coeffs=\pflcoeffsreflexion]%
          {\RFXlistedecaleespline}%
      }%
    }%
  }%
  {%
    \ifboolKV[GraphiqueTikzReflexion]{Interpo}%
    {%
      %---cas INTERPO---
      \tkzg@reflexion@interpo{#2}{\pflaxereflexion}%
      \DefinirCourbeInterpo%
        [Trace,%
        Couleur={\useKV[GraphiqueTikzReflexion]{Couleur}},%
        Nom=\pflnamereflexion,%
        StyleTrace=\pflstylereflexion,%
        Tension=\pfltensiontransfo]%
        {\RFXlistedecaleeinterpo}%
    }%
    {%
      %---cas FORMULE xint---
      \IfStrEq{\pflstepreflexion}{}%
      {%
        \xdef\pflstepreflexion{\xintfloateval{%
            ((\useKV[GraphiqueTikzReflexion]{Fin})-%
            (\useKV[GraphiqueTikzReflexion]{Debut}))/100}}%
      }%
      {}%
      \IfStrEqCase{\pflaxereflexion}{%
        {x}{%
          % -f(x) : on définit g(x) = -f(x)
          \xintdeffloatfunc pflreflexion(x) := -(#2(x)) ;%
        }%
        {y}{%
          % f(-x) : on définit g(x) = f(-x)
          \xintdeffloatfunc pflreflexion(x) := #2(-(x)) ;%
        }%
        {yx}{%
          %
        }%
      }%
      \ifboolKV[GraphiqueTikzReflexion]{Clip}%
      {\begin{scope}%
          \clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax}) ;}%
        {}%
        \IfStrEq{\pflaxereflexion}{yx}%
        {%
          %---cas yx : courbe paramétrique (f(t), t)---
          \IfEq{\pflnamereflexion}{}%
          {%
            \draw[pflcourbe,\pflstylereflexion,%
            {\useKV[GraphiqueTikzReflexion]{Couleur}}]
            plot[smooth] coordinates {%
              \xintthecoords\xintfloatexpr
              seq((#2(t), t),
              t=\useKV[GraphiqueTikzReflexion]{Debut}%
              ..[\pflstepreflexion]..%
              \useKV[GraphiqueTikzReflexion]{Fin},%
              \useKV[GraphiqueTikzReflexion]{Fin})
              \relax
            } ;%
          }%
          {%
            \path[draw,pflcourbe,\pflstylereflexion,%
            {\useKV[GraphiqueTikzReflexion]{Couleur}},%
            name path global=\pflnamereflexion]
            plot[smooth] coordinates {%
              \xintthecoords\xintfloatexpr
              seq((#2(t), t),
              t=\useKV[GraphiqueTikzReflexion]{Debut}%
              ..[\pflstepreflexion]..%
              \useKV[GraphiqueTikzReflexion]{Fin},%
              \useKV[GraphiqueTikzReflexion]{Fin})
              \relax
            } ;%
          }%
        }%
        {%
          %---cas x et y : tracé classique de pflreflexion---
          \IfEq{\pflnamereflexion}{}%
          {%
            \draw[pflcourbe,\pflstylereflexion,%
            {\useKV[GraphiqueTikzReflexion]{Couleur}}]
            plot[smooth] coordinates {%
              \xintthecoords\xintfloatexpr
              seq((x, pflreflexion(x)),
              x=\useKV[GraphiqueTikzReflexion]{Debut}%
              ..[\pflstepreflexion]..%
              \useKV[GraphiqueTikzReflexion]{Fin},%
              \useKV[GraphiqueTikzReflexion]{Fin})
              \relax
            } ;%
          }%
          {%
            \path[draw,pflcourbe,\pflstylereflexion,%
            {\useKV[GraphiqueTikzReflexion]{Couleur}},%
            name path global=\pflnamereflexion]
            plot[smooth] coordinates {%
              \xintthecoords\xintfloatexpr
              seq((x, pflreflexion(x)),
              x=\useKV[GraphiqueTikzReflexion]{Debut}%
              ..[\pflstepreflexion]..%
              \useKV[GraphiqueTikzReflexion]{Fin},%
              \useKV[GraphiqueTikzReflexion]{Fin})
              \relax
            } ;%
          }%
        }%
        \ifboolKV[GraphiqueTikzReflexion]{Clip}{\end{scope}}{}%
    }%
  }%
}

%====POLYNÔME DE TAYLOR / MACLAURIN
\defKV[GraphiqueTikzTaylor]{%
  Ordre=\def\pfltaylorordre{#1},%
  h=\def\pfltaylorh{#1},%
  Nom=\def\pfltaylornom{#1},%
  StyleTrace=\def\pfltaylorstyle{#1},%
  Pas=\def\pfltaylorpas{#1}%
}

\setKVdefault[GraphiqueTikzTaylor]{%
  Ordre=5,%
  h=0.01,%
  Couleur=black,%
  Debut={\pflxmin},%
  Fin={\pflxmax},%
  Pas={},%
  Clip=true,%
  Trace=false,%
  Nom={},%
  StyleTrace={}%
}

\NewDocumentCommand\DefinirTaylor{ O{} D<>{taylorN} m m }{%
  %#1 = clés
  %#2 = nom de la fonction Taylor (pour réutilisation)
  %#3 = nom de la fonction xint originale
  %#4 = point de développement a
  \restoreKV[GraphiqueTikzTaylor]%
  \setKV[GraphiqueTikzTaylor]{#1}%
  % calcul du pas de tracé si non fourni
  \IfStrEq{\pfltaylorpas}{}%
  {%
    \xdef\pfltaylorpas{\xintfloateval{%
        ((\useKV[GraphiqueTikzTaylor]{Fin})-(\useKV[GraphiqueTikzTaylor]{Debut}))/100}}%
  }%
  {}%
  % construction du polynôme
  \tkzg@taylor@build{#3}{\pfltaylorordre}{#4}{\pfltaylorh}%
  % on nomme la fonction pour réutilisation
  \xintdeffloatfunc #2(x) := pfltaylorpoly(x) ;%
  % tracé conditionnel
  \ifboolKV[GraphiqueTikzTaylor]{Clip}%
  {\begin{scope}\clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax}) ;}%
    {}%
    \ifboolKV[GraphiqueTikzTaylor]{Trace}%
    {%
      \IfEq{\pfltaylornom}{}%
      {%
        \draw[pflcourbe,\pfltaylorstyle,{\useKV[GraphiqueTikzTaylor]{Couleur}}]
        plot[smooth] coordinates {%
          \xintthecoords\xintfloatexpr
          seq((x, min(max(pfltaylorpoly(x),\pflMinoffsetV),\pflMaxoffsetV)),
          x=\useKV[GraphiqueTikzTaylor]{Debut}%
          ..[\pfltaylorpas]..%
          \useKV[GraphiqueTikzTaylor]{Fin},%
          \useKV[GraphiqueTikzTaylor]{Fin})
          \relax
        } ;%
      }%
      {%
        \path[draw,pflcourbe,\pfltaylorstyle,%
        {\useKV[GraphiqueTikzTaylor]{Couleur}},%
        name path global=\pfltaylornom]
        plot[smooth] coordinates {%
          \xintthecoords\xintfloatexpr
          seq((x, min(max(pfltaylorpoly(x),\pflMinoffsetV),\pflMaxoffsetV)),
          x=\useKV[GraphiqueTikzTaylor]{Debut}%
          ..[\pfltaylorpas]..%
          \useKV[GraphiqueTikzTaylor]{Fin},%
          \useKV[GraphiqueTikzTaylor]{Fin})
          \relax
        } ;%
      }%
    }%
    {%
      % pas de tracé mais path nommé si Nom= fourni
      \IfEq{\pfltaylornom}{}%
      {}%
      {%
        \path[draw=none,pflcourbe,name path global=\pfltaylornom]
        plot[smooth] coordinates {%
          \xintthecoords\xintfloatexpr
          seq((x, min(max(pfltaylorpoly(x),\pflMinoffsetV),\pflMaxoffsetV)),
          x=\useKV[GraphiqueTikzTaylor]{Debut}%
          ..[\pfltaylorpas]..%
          \useKV[GraphiqueTikzTaylor]{Fin},%
          \useKV[GraphiqueTikzTaylor]{Fin})
          \relax
        } ;%
      }%
    }%
    \ifboolKV[GraphiqueTikzTaylor]{Clip}{\end{scope}}{}%
}

%---commande \TracerTaylor
\NewDocumentCommand\TracerTaylor{ O{} m m }{%
  %#1 = clés
  %#2 = nom de la fonction xint originale
  %#3 = point de développement a
  \restoreKV[GraphiqueTikzTaylor]%
  \setKV[GraphiqueTikzTaylor]{#1}%
  % calcul du pas de tracé si non fourni
  \IfStrEq{\pfltaylorpas}{}%
  {%
    \xdef\pfltaylorpas{\xintfloateval{%
        ((\useKV[GraphiqueTikzTaylor]{Fin})-(\useKV[GraphiqueTikzTaylor]{Debut}))/100}}%
  }%
  {}%
  % construction du polynôme
  \tkzg@taylor@build{#2}{\pfltaylorordre}{#3}{\pfltaylorh}%
  % tracé
  \ifboolKV[GraphiqueTikzTaylor]{Clip}%
  {\begin{scope}\clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax}) ;}%
    {}%
    \IfEq{\pfltaylornom}{}%
    {%
      \draw[pflcourbe,\pfltaylorstyle,{\useKV[GraphiqueTikzTaylor]{Couleur}}]
      plot[smooth] coordinates {%
        \xintthecoords\xintfloatexpr
        seq((x, min(max(pfltaylorpoly(x),\pflMinoffsetV),\pflMaxoffsetV)),
        x=\useKV[GraphiqueTikzTaylor]{Debut}%
        ..[\pfltaylorpas]..%
        \useKV[GraphiqueTikzTaylor]{Fin},%
        \useKV[GraphiqueTikzTaylor]{Fin})
        \relax
      } ;%
    }%
    {%
      \path[draw,pflcourbe,\pfltaylorstyle,%
      {\useKV[GraphiqueTikzTaylor]{Couleur}},%
      name path global=\pfltaylornom]
      plot[smooth] coordinates {%
        \xintthecoords\xintfloatexpr
        seq((x, min(max(pfltaylorpoly(x),\pflMinoffsetV),\pflMaxoffsetV)),
        x=\useKV[GraphiqueTikzTaylor]{Debut}%
        ..[\pfltaylorpas]..%
        \useKV[GraphiqueTikzTaylor]{Fin},%
        \useKV[GraphiqueTikzTaylor]{Fin})
        \relax
      } ;%
    }%
    \ifboolKV[GraphiqueTikzTaylor]{Clip}{\end{scope}}{}%
}

%====LOI EXPO
\defKV[GraphiqueTikzLoiProbasCont]{%
  Pas=\def\pflloiprobastep{#1},%
  Nom=\def\pflloiprobaname{#1}
}

\setKVdefault[GraphiqueTikzLoiProbasCont]{%
  Nom=densite,%
  Couleur=black,%
  Trace=false,%
  Pas={},%
  Debut={\pflxmin},%
  Fin={\pflxmax}
}

\NewDocumentCommand\DefinirLoiExponentielle{ O{} D<>{fdexpo} m }{%
  %1=options
  %2=mu
  %3=sigma
  \restoreKV[GraphiqueTikzLoiProbasCont]%
  \setKV[GraphiqueTikzLoiProbasCont]{#1}%
  \xintdeffloatfunc #2(x) := (#3)*exp(-(#3)*x) ;%
  \IfStrEq{\pflloiprobastep}{}%
  {%
    \xdef\pflloiprobastep{\xintfloateval{((\useKV[GraphiqueTikzLoiProbasCont]{Fin})-(\useKV[GraphiqueTikzLoiProbasCont]{Debut}))/100}}%
  }%
  {}%
  \begin{scope}
    \clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax});
    \ifboolKV[GraphiqueTikzLoiProbasCont]{Trace}%
    {%
      \path[draw,pflcourbe,{\useKV[GraphiqueTikzLoiProbasCont]{Couleur}},name path global=\pflloiprobaname] plot[smooth] coordinates {%
        \xintthecoords\xintfloatexpr
        seq((x,#2(x)),x={\useKV[GraphiqueTikzLoiProbasCont]{Debut}}..[\pflloiprobastep]..{\useKV[GraphiqueTikzLoiProbasCont]{Fin}},{\useKV[GraphiqueTikzLoiProbasCont]{Fin}})
        \relax
      } ;
    }%
    {%
      \path[draw=none,pflcourbe,name path global=\pflloiprobaname]  plot[smooth] coordinates {%
        \xintthecoords\xintfloatexpr
        seq((x,#2(x)),x={\useKV[GraphiqueTikzLoiProbasCont]{Debut}}..[\pflloiprobastep]..{\useKV[GraphiqueTikzLoiProbasCont]{Fin}},{\useKV[GraphiqueTikzLoiProbasCont]{Fin}})
        \relax
      } ;
    }%
  \end{scope}
}

\NewDocumentCommand\TracerLoiExponentielle{ O{} m }{%
  %1=options
  %2=mu
  %3=sigma
  \restoreKV[GraphiqueTikzLoiProbasCont]%
  \setKV[GraphiqueTikzLoiProbasCont]{#1}%
  \IfStrEq{\pflloiprobastep}{}%
  {%
    \xdef\pflloiprobastep{\xintfloateval{((\useKV[GraphiqueTikzLoiProbasCont]{Fin})-(\useKV[GraphiqueTikzLoiProbasCont]{Debut}))/100}}%
  }%
  {}%
  \begin{scope}
    \clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax});
    \draw[pflcourbe,{\useKV[GraphiqueTikzLoiProbasCont]{Couleur}}]  plot[smooth] coordinates {%
      \xintthecoords\xintfloatexpr
      seq((x,#2),x={\useKV[GraphiqueTikzLoiProbasCont]{Debut}}..[\pflloiprobastep]..{\useKV[GraphiqueTikzLoiProbasCont]{Fin}},{\useKV[GraphiqueTikzLoiProbasCont]{Fin}})
      \relax
    } ;
  \end{scope}
}

%====LOI DE STUDENT
% f(x) = Γ((ν+1)/2) / (√(νπ)·Γ(ν/2)) · (1+x²/ν)^(-(ν+1)/2)
% #2 = nom fonction xint  #3 = ν (degrés de liberté)
\NewDocumentCommand\DefinirLoiStudent{ O{} D<>{fdstudent} m }{%
  %#1=options  #2=nom fonction  #3=ν
  \restoreKV[GraphiqueTikzLoiProbasCont]%
  \setKV[GraphiqueTikzLoiProbasCont]{#1}%
  \xintdeffloatfunc #2(x) :=
    pflgamma((#3+1)/2) / (sqrt((#3)*pi)*pflgamma((#3)/2))
    * (1+(x)^2/(#3))^(-((#3+1)/2)) ;%
  \IfStrEq{\pflloiprobastep}{}%
  {%
    \xdef\pflloiprobastep{\xintfloateval{%
      ((\useKV[GraphiqueTikzLoiProbasCont]{Fin})-(\useKV[GraphiqueTikzLoiProbasCont]{Debut}))/100}}%
  }{}%
  \begin{scope}
    \clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax});
    \ifboolKV[GraphiqueTikzLoiProbasCont]{Trace}%
    {%
      \path[draw,pflcourbe,{\useKV[GraphiqueTikzLoiProbasCont]{Couleur}},name path global=\pflloiprobaname]
        plot[smooth] coordinates {%
          \xintthecoords\xintfloatexpr
          seq((x,#2(x)),
          x={\useKV[GraphiqueTikzLoiProbasCont]{Debut}}%
          ..[\pflloiprobastep]..%
          {\useKV[GraphiqueTikzLoiProbasCont]{Fin}},%
          {\useKV[GraphiqueTikzLoiProbasCont]{Fin}})
          \relax
        } ;
    }%
    {%
      \path[draw=none,pflcourbe,name path global=\pflloiprobaname]
        plot[smooth] coordinates {%
          \xintthecoords\xintfloatexpr
          seq((x,#2(x)),
          x={\useKV[GraphiqueTikzLoiProbasCont]{Debut}}%
          ..[\pflloiprobastep]..%
          {\useKV[GraphiqueTikzLoiProbasCont]{Fin}},%
          {\useKV[GraphiqueTikzLoiProbasCont]{Fin}})
          \relax
        } ;
    }%
  \end{scope}
}

\NewDocumentCommand\TracerLoiStudent{ O{} m }{%
  %#1=options  #2=nom fonction xint (définie par \DefinirLoiStudent)
  \restoreKV[GraphiqueTikzLoiProbasCont]%
  \setKV[GraphiqueTikzLoiProbasCont]{#1}%
  \IfStrEq{\pflloiprobastep}{}%
  {%
    \xdef\pflloiprobastep{\xintfloateval{%
      ((\useKV[GraphiqueTikzLoiProbasCont]{Fin})-(\useKV[GraphiqueTikzLoiProbasCont]{Debut}))/100}}%
  }{}%
  \begin{scope}
    \clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax});
    \draw[pflcourbe,{\useKV[GraphiqueTikzLoiProbasCont]{Couleur}}]
      plot[smooth] coordinates {%
        \xintthecoords\xintfloatexpr
        seq((x,#2),
        x={\useKV[GraphiqueTikzLoiProbasCont]{Debut}}%
        ..[\pflloiprobastep]..%
        {\useKV[GraphiqueTikzLoiProbasCont]{Fin}},%
        {\useKV[GraphiqueTikzLoiProbasCont]{Fin}})
        \relax
      } ;
  \end{scope}
}

%====LOI DE FISCHER (F de Snedecor)
% f(x) = Γ((d1+d2)/2)/(Γ(d1/2)·Γ(d2/2)) · (d1/d2)^(d1/2) · x^(d1/2-1) · (1+d1·x/d2)^(-(d1+d2)/2)
% définie pour x > 0 → penser à mettre Debut=0.001
% #3 = d1, #4 = d2 (degrés de liberté)
\NewDocumentCommand\DefinirLoiFischer{ O{} D<>{fdfischer} m m }{%
  %#1=options  #2=nom fonction  #3=d1  #4=d2
  \restoreKV[GraphiqueTikzLoiProbasCont]%
  \setKV[GraphiqueTikzLoiProbasCont]{#1}%
  \xintdeffloatfunc #2(x) :=
    (pflgamma((#3+(#4))/2)/(pflgamma((#3)/2)*pflgamma((#4)/2)))
    * ((#3)/(#4))^((#3)/2) * (x)^((#3)/2-1)
    * (1+(#3)*(x)/(#4))^(-((#3+(#4))/2)) ;%
  \IfStrEq{\pflloiprobastep}{}%
  {%
    \xdef\pflloiprobastep{\xintfloateval{%
      ((\useKV[GraphiqueTikzLoiProbasCont]{Fin})-(\useKV[GraphiqueTikzLoiProbasCont]{Debut}))/100}}%
  }{}%
  \xdef\tmpminloifischer{\xintfloateval{max(0.001,\useKV[GraphiqueTikzLoiProbasCont]{Debut})}}%
  \begin{scope}
    \clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax});
    \ifboolKV[GraphiqueTikzLoiProbasCont]{Trace}%
    {%
      \path[draw,pflcourbe,{\useKV[GraphiqueTikzLoiProbasCont]{Couleur}},name path global=\pflloiprobaname]
        plot[smooth] coordinates {%
          \xintthecoords\xintfloatexpr
          seq((x,#2(x)),
          x={\tmpminloifischer}%
          ..[\pflloiprobastep]..%
          {\useKV[GraphiqueTikzLoiProbasCont]{Fin}},%
          {\useKV[GraphiqueTikzLoiProbasCont]{Fin}})
          \relax
        } ;
    }%
    {%
      \path[draw=none,pflcourbe,name path global=\pflloiprobaname]
        plot[smooth] coordinates {%
          \xintthecoords\xintfloatexpr
          seq((x,#2(x)),
          x={\tmpminloifischer}%
          ..[\pflloiprobastep]..%
          {\useKV[GraphiqueTikzLoiProbasCont]{Fin}},%
          {\useKV[GraphiqueTikzLoiProbasCont]{Fin}})
          \relax
        } ;
    }%
  \end{scope}
}

\NewDocumentCommand\TracerLoiFischer{ O{} m }{%
  %#1=options  #2=nom fonction xint (définie par \DefinirLoiFischer)
  \restoreKV[GraphiqueTikzLoiProbasCont]%
  \setKV[GraphiqueTikzLoiProbasCont]{#1}%
  \IfStrEq{\pflloiprobastep}{}%
  {%
    \xdef\pflloiprobastep{\xintfloateval{%
      ((\useKV[GraphiqueTikzLoiProbasCont]{Fin})-(\useKV[GraphiqueTikzLoiProbasCont]{Debut}))/100}}%
  }{}%
  \xdef\tmpminloifischer{\xintfloateval{max(0.001,\useKV[GraphiqueTikzLoiProbasCont]{Debut})}}%
  \begin{scope}
    \clip ({\pflxmin},{\pflymin}) rectangle ({\pflxmax},{\pflymax});
    \draw[pflcourbe,{\useKV[GraphiqueTikzLoiProbasCont]{Couleur}}]
      plot[smooth] coordinates {%
        \xintthecoords\xintfloatexpr
        seq((x,#2),
        x={\tmpminloifischer}%
        ..[\pflloiprobastep]..%
        {\useKV[GraphiqueTikzLoiProbasCont]{Fin}},%
        {\useKV[GraphiqueTikzLoiProbasCont]{Fin}})
        \relax
      } ;
  \end{scope}
}
%alias intégrale--proba ;-)
\NewCommandCopy\RepresenterProbaContinue\TracerIntegrale

%====HISTO POISSON
% P(X=k) = e^(-λ) * λ^k / k!
% #3 = λ (paramètre), k = 0,1,2,...
\defKV[tkzHistoPoisson]{%
  CouleurTraits=\def\tkzGraphPoissonColTraits{#1},%
  Plage=\def\tkzGraphPoissonPlage{#1},%
  CouleurPlage=\def\tkzGraphPoissonColPlage{#1},%
  ClipX=\def\tkzGraphPoissonXminmax{#1},%
  CouleurNormale=\def\tkzGraphPoissonColNorm{#1},%
  Nmax=\def\tkzGraphPoissonNmax{#1},%
  Style=\def\tkzGraphPoissonStyle{#1}
}
\setKVdefault[tkzHistoPoisson]{%
  CouleurTraits=black,%
  Plage={},%
  CouleurPlage=black,%
  ClipX={},%
  AffNormale=false,%
  CouleurNormale=black,%
  Nmax={},%
  Style=histo
}
\NewDocumentCommand\TracerLoiPoisson{ O{} D<>{phipoisson} m }{%
  % #1=clés  #2=nom courbe normale approx  #3=λ
  \restoreKV[tkzHistoPoisson]%
  \setKV[tkzHistoPoisson]{#1}%
  \def\tkzGraphPoissonL{#3}%
  % Nmax auto si non fourni : on prend λ + 4√λ arrondi
  \IfStrEq{\tkzGraphPoissonNmax}{}%
    {\xdef\tkzGraphPoissonNmax{\xinttheexpr round(#3+4*sqrt(#3))\relax}}%
    {}%
  % bornes d'affichage
  \IfStrEq{\tkzGraphPoissonXminmax}{}%
    {%
      \xdef\tkzGraphPoissonXmin{0}%
      \xdef\tkzGraphPoissonXmax{\tkzGraphPoissonNmax}%
    }%
    {%
      \StrCut{\tkzGraphPoissonXminmax}{-}{\tkzGraphPoissonXmin}{\tkzGraphPoissonXmax}%
      \IfStrEq{\tkzGraphPoissonXmin}{*}{\xdef\tkzGraphPoissonXmin{0}}{}%
      \IfStrEq{\tkzGraphPoissonXmax}{*}{\xdef\tkzGraphPoissonXmax{\tkzGraphPoissonNmax}}{}%
    }%
  % bornes de coloriage
  \IfStrEq{\tkzGraphPoissonPlage}{}%
    {}%
    {%
      \StrCut{\tkzGraphPoissonPlage}{-}{\tkzGraphPoissonColorMin}{\tkzGraphPoissonColorMax}%
      \IfStrEq{\tkzGraphPoissonColorMin}{*}{\xdef\tkzGraphPoissonColorMin{\tkzGraphPoissonXmin}}{}%
      \IfStrEq{\tkzGraphPoissonColorMax}{*}{\xdef\tkzGraphPoissonColorMax{\tkzGraphPoissonXmax}}{}%
    }%
  % coloriage éventuel
  \IfStrEq{\tkzGraphPoissonPlage}{}%
    {}%
    {%
      \xintFor* ##1 in {\xintSeq{\tkzGraphPoissonColorMin}{\tkzGraphPoissonColorMax}}\do{%
        \xdef\tkztmpYYY{\xintfloateval{exp(-(#3))*(#3)^(##1)/factorial(##1)}}%
		%
		\IfStrEq{\tkzGraphPoissonStyle}{batons}%
		{%
		  \draw[pflbarresprobas,\tkzGraphPoissonColPlage] ({##1},{\pflymin}) -- ({##1},{\tkztmpYYY-\pflymin}) ;
		  
		}%
		{%
		  \draw[draw=none,fill=\tkzGraphPoissonColPlage,fill opacity=0.5] ({##1-0.5},{\pflymin}) rectangle++ (1,{\tkztmpYYY-\pflymin}) ;
		}%
		%
      }%
    }%
  % tracé
  \xintFor* ##1 in {\xintSeq{\tkzGraphPoissonXmin}{\tkzGraphPoissonXmax}}\do{%
    \xdef\tkztmpYYY{\xintfloateval{exp(-(#3))*(#3)^(##1)/factorial(##1)}}%
	\IfStrEq{\tkzGraphPoissonStyle}{batons}%
	{%
		\IfStrEq{\tkzGraphPoissonPlage}{}%si plage, on colorie tout
			{%
				\draw[pflbarresprobas,\tkzGraphPoissonColTraits] ({##1},{\pflymin}) -- ({##1},{\tkztmpYYY-\pflymin}) ;
			}%
			{%
				\xintifboolexpr{\tkzGraphPoissonColorMin <= ##1 <= \tkzGraphPoissonColorMax}%
					{}%
					{%
						\draw[pflbarresprobas,\tkzGraphPoissonColTraits] ({##1},{\pflymin}) -- ({##1},{\tkztmpYYY-\pflymin}) ;
					}%
			}%
	}%
	{%
		\draw[pfltrait,\tkzGraphPoissonColTraits] ({##1-0.5},{\pflymin}) rectangle++ (1,{\tkztmpYYY-\pflymin}) ;
	}%
  }%
  % approximation normale : N(λ, √λ) (why not !)
  \ifboolKV[tkzHistoPoisson]{AffNormale}%
    {%
      \xdef\tkzMinNormHistoPoisson{\xintfloateval{\tkzGraphPoissonXmin-0.5}}%
      \xdef\tkzMaxNormHistoPoisson{\xintfloateval{\tkzGraphPoissonXmax+0.5}}%
      \xdef\tkzEsperNorm{\xintfloateval{#3}}%
      \xdef\tkzVarNorm{\xintfloateval{sqrt(#3)}}%
      \DefinirLoiNormale[Trace,Couleur=\tkzGraphPoissonColNorm,pflcourbe,%
        Debut=\tkzMinNormHistoPoisson,Fin=\tkzMaxNormHistoPoisson]%
        <#2>{\tkzEsperNorm}{\tkzVarNorm}%
    }%
    {}%
}

%====HISTO HYPERGÉOMÉTRIQUE
% P(X=k) = C(K,k)*C(N-K,n-k) / C(N,n)
% #3=N (population totale)  #4=K (succès dans population)  #5=n (taille tirage)
% k varie de max(0,n+K-N) à min(n,K)
\defKV[tkzHistoHyperGeo]{%
  CouleurTraits=\def\tkzGraphHyperColTraits{#1},%
  Plage=\def\tkzGraphHyperPlage{#1},%
  CouleurPlage=\def\tkzGraphHyperColPlage{#1},%
  ClipX=\def\tkzGraphHyperXminmax{#1},%
  CouleurNormale=\def\tkzGraphHyperColNorm{#1},%
  Style=\def\tkzGraphHyperStyle{#1}
}
\setKVdefault[tkzHistoHyperGeo]{%
  CouleurTraits=black,%
  Plage={},%
  CouleurPlage=black,%
  ClipX={},%
  AffNormale=false,%
  CouleurNormale=black,%
  Style=histo
}
\NewDocumentCommand\TracerLoiHyperGeo{ O{} D<>{phihypergeo} m m m }{%
  % #1=clés  #2=nom courbe normale approx  #3=N  #4=K  #5=n
  \restoreKV[tkzHistoHyperGeo]%
  \setKV[tkzHistoHyperGeo]{#1}%
  % bornes naturelles de k
  \xdef\tkzGraphHyperKmin{\xinttheexpr max(0,#5+#4-#3)\relax}%
  \xdef\tkzGraphHyperKmax{\xinttheexpr min(#5,#4)\relax}%
  % bornes d'affichage
  \IfStrEq{\tkzGraphHyperXminmax}{}%
    {%
      \xdef\tkzGraphHyperXmin{\tkzGraphHyperKmin}%
      \xdef\tkzGraphHyperXmax{\tkzGraphHyperKmax}%
    }%
    {%
      \StrCut{\tkzGraphHyperXminmax}{-}{\tkzGraphHyperXmin}{\tkzGraphHyperXmax}%
      \IfStrEq{\tkzGraphHyperXmin}{*}{\xdef\tkzGraphHyperXmin{\tkzGraphHyperKmin}}{}%
      \IfStrEq{\tkzGraphHyperXmax}{*}{\xdef\tkzGraphHyperXmax{\tkzGraphHyperKmax}}{}%
    }%
  % bornes de coloriage
  \IfStrEq{\tkzGraphHyperPlage}{}%
    {}%
    {%
      \StrCut{\tkzGraphHyperPlage}{-}{\tkzGraphHyperColorMin}{\tkzGraphHyperColorMax}%
      \IfStrEq{\tkzGraphHyperColorMin}{*}{\xdef\tkzGraphHyperColorMin{\tkzGraphHyperXmin}}{}%
      \IfStrEq{\tkzGraphHyperColorMax}{*}{\xdef\tkzGraphHyperColorMax{\tkzGraphHyperXmax}}{}%
    }%
  % coloriage éventuel
  \IfStrEq{\tkzGraphHyperPlage}{}%
    {}%
    {%
      \xintFor* ##1 in {\xintSeq{\tkzGraphHyperColorMin}{\tkzGraphHyperColorMax}}\do{%
        \xdef\tkztmpYYY{\xintfloateval{binomial(#4,##1)*binomial(#3-(#4),#5-(##1))/binomial(#3,#5)}}%
    \IfStrEq{\tkzGraphHyperStyle}{batons}%
      {%
        \draw[pflbarresprobas,\tkzGraphHyperColPlage] ({##1},{\pflymin}) -- ({##1},{\tkztmpYYY-\pflymin}) ;
      }%
      {%
        \draw[draw=none,fill=\tkzGraphHyperColPlage,fill opacity=0.5] ({##1-0.5},{\pflymin}) rectangle++ (1,{\tkztmpYYY-\pflymin}) ;
      }%
      }%
    }%
  % tracé
  \xintFor* ##1 in {\xintSeq{\tkzGraphHyperXmin}{\tkzGraphHyperXmax}}\do{%
    \xdef\tkztmpYYY{\xintfloateval{binomial(#4,##1)*binomial(#3-(#4),#5-(##1))/binomial(#3,#5)}}%
  %
  \IfStrEq{\tkzGraphHyperStyle}{batons}%
  {%
    \IfStrEq{\tkzGraphHyperPlage}{}%si plage, on colorie tout
      {%
        \draw[pflbarresprobas,\tkzGraphHyperColTraits] ({##1},{\pflymin}) -- ({##1},{\tkztmpYYY-\pflymin}) ;
      }%
      {%
        \xintifboolexpr{\tkzGraphHyperColorMin <= ##1 <= \tkzGraphHyperColorMax}%
          {}%
          {%
            \draw[pflbarresprobas,\tkzGraphHyperColTraits] ({##1},{\pflymin}) -- ({##1},{\tkztmpYYY-\pflymin}) ;
          }%
      }%
  }%
  {%
    \draw[pfltrait,\tkzGraphHyperColTraits] ({##1-0.5},{\pflymin}) rectangle++ (1,{\tkztmpYYY-\pflymin}) ;
  }%
  %
  }%
  % approximation normale : N(nK/N, √(nK(N-K)(N-n)/(N²(N-1))))
  \ifboolKV[tkzHistoHyperGeo]{AffNormale}%
    {%
      \xdef\tkzMinNormHistoHyper{\xintfloateval{\tkzGraphHyperXmin-0.5}}%
      \xdef\tkzMaxNormHistoHyper{\xintfloateval{\tkzGraphHyperXmax+0.5}}%
      \xdef\tkzEsperNorm{\xintfloateval{(#5)*(#4)/(#3)}}%
      \xdef\tkzVarNorm{\xintfloateval{sqrt((#5)*(#4)*((#3)-(#4))*((#3)-(#5))/((#3)^2*((#3)-1)))}}%
      \DefinirLoiNormale[Trace,Couleur=\tkzGraphHyperColNorm,pflcourbe,%
        Debut=\tkzMinNormHistoHyper,Fin=\tkzMaxNormHistoHyper]%
        <#2>{\tkzEsperNorm}{\tkzVarNorm}%
    }%
    {}%
}

%====HISTO LOI GÉOMÉTRIQUE
% P(X=k) = (1-p)^(k-1) * p  pour k = 1, 2, 3, ...
% #3 = p (probabilité de succès)
\defKV[tkzHistoGeo]{%
  CouleurTraits=\def\tkzGraphGeoColTraits{#1},%
  Plage=\def\tkzGraphGeoPlage{#1},%
  CouleurPlage=\def\tkzGraphGeoColPlage{#1},%
  ClipX=\def\tkzGraphGeoXminmax{#1},%
  Nmax=\def\tkzGraphGeoNmax{#1},%
  Style=\def\tkzGraphGeoStyle{#1},%
  CouleurExpo=\def\tkzGraphGeoColExpo{#1}
}
\setKVdefault[tkzHistoGeo]{%
  CouleurTraits=black,%
  Plage={},%
  CouleurPlage=black,%
  ClipX={},%
  Nmax={},%
  Style=histo,%
  AffExpo=false,%
  CouleurExpo=black
}
\NewDocumentCommand\TracerLoiGeo{ O{} m }{%
  % #1=clés  #2=p
  \restoreKV[tkzHistoGeo]%
  \setKV[tkzHistoGeo]{#1}%
  % Nmax auto si non fourni : 1/p + 4*sqrt((1-p)/p²)
  \IfStrEq{\tkzGraphGeoNmax}{}%
    {\xdef\tkzGraphGeoNmax{\xinttheexpr round(1/(#2)+4*sqrt((1-(#2))/(#2)^2))\relax}}%
    {}%
  % bornes d'affichage
  \IfStrEq{\tkzGraphGeoXminmax}{}%
    {%
      \xdef\tkzGraphGeoXmin{1}%
      \xdef\tkzGraphGeoXmax{\tkzGraphGeoNmax}%
    }%
    {%
      \StrCut{\tkzGraphGeoXminmax}{-}{\tkzGraphGeoXmin}{\tkzGraphGeoXmax}%
      \IfStrEq{\tkzGraphGeoXmin}{*}{\xdef\tkzGraphGeoXmin{1}}{}%
      \IfStrEq{\tkzGraphGeoXmax}{*}{\xdef\tkzGraphGeoXmax{\tkzGraphGeoNmax}}{}%
    }%
  % bornes de coloriage
  \IfStrEq{\tkzGraphGeoPlage}{}%
    {}%
    {%
      \StrCut{\tkzGraphGeoPlage}{-}{\tkzGraphGeoColorMin}{\tkzGraphGeoColorMax}%
      \IfStrEq{\tkzGraphGeoColorMin}{*}{\xdef\tkzGraphGeoColorMin{\tkzGraphGeoXmin}}{}%
      \IfStrEq{\tkzGraphGeoColorMax}{*}{\xdef\tkzGraphGeoColorMax{\tkzGraphGeoXmax}}{}%
    }%
  % coloriage éventuel
  \IfStrEq{\tkzGraphGeoPlage}{}%
    {}%
    {%
      \xintFor* ##1 in {\xintSeq{\tkzGraphGeoColorMin}{\tkzGraphGeoColorMax}}\do{%
        \xdef\tkztmpYYY{\xintfloateval{(1-(#2))^(##1-1)*(#2)}}%
        \IfStrEq{\tkzGraphGeoStyle}{batons}%
        {%
          \draw[pflbarresprobas,\tkzGraphGeoColPlage] ({##1},{\pflymin}) -- ({##1},{\tkztmpYYY-\pflymin}) ;
        }%
        {%
          \draw[draw=none,fill=\tkzGraphGeoColPlage,fill opacity=0.5] ({##1-0.5},{\pflymin}) rectangle++ (1,{\tkztmpYYY-\pflymin}) ;
        }%
      }%
    }%
  % tracé
  \xintFor* ##1 in {\xintSeq{\tkzGraphGeoXmin}{\tkzGraphGeoXmax}}\do{%
    \xdef\tkztmpYYY{\xintfloateval{(1-(#2))^(##1-1)*(#2)}}%
    \IfStrEq{\tkzGraphGeoStyle}{batons}%
    {%
      \IfStrEq{\tkzGraphGeoPlage}{}%
        {%
          \draw[pflbarresprobas,\tkzGraphGeoColTraits] ({##1},{\pflymin}) -- ({##1},{\tkztmpYYY-\pflymin}) ;
        }%
        {%
          \xintifboolexpr{\tkzGraphGeoColorMin <= ##1 <= \tkzGraphGeoColorMax}%
            {}%
            {%
              \draw[pflbarresprobas,\tkzGraphGeoColTraits] ({##1},{\pflymin}) -- ({##1},{\tkztmpYYY-\pflymin}) ;
            }%
        }%
    }%
    {%
      \draw[pfltrait,\tkzGraphGeoColTraits] ({##1-0.5},{\pflymin}) rectangle++ (1,{\tkztmpYYY-\pflymin}) ;
    }%
  }%
  \ifboolKV[tkzHistoGeo]{AffExpo}%
  {%
    \xdef\tkzMinExpoGeo{\xintfloateval{\tkzGraphGeoXmin-0.5}}%
    \xdef\tkzMaxExpoGeo{\xintfloateval{\tkzGraphGeoXmax+0.5}}%
    \xdef\tkzExpoParam{\xintfloateval{-ln(1-(#2))}}%
    \DefinirLoiExponentielle[Trace,Couleur=\tkzGraphGeoColExpo,pflcourbe,%
      Debut=\tkzMinExpoGeo,Fin=\tkzMaxExpoGeo]%
      <phiexpo>{\tkzExpoParam}%
  }%
  {}%
}

%====HISTOBINOM (mis à jour : CouleurTraits + Style)
\defKV[tkzHistoBinom]{%
  CouleurTraits=\def\tkzGraphBinomColTraits{#1},%
  Plage=\def\tkzGraphBinomPlage{#1},%
  CouleurPlage=\def\tkzGraphBimomColPlage{#1},%
  ClipX=\def\tkzGraphBinomXminmax{#1},%
  CouleurNormale=\def\tkzGraphBinomColNorm{#1},%
  Style=\def\tkzGraphBinomStyle{#1}
}
\setKVdefault[tkzHistoBinom]{%
  CouleurTraits=black,%
  Plage={},%
  CouleurPlage=black,%
  ClipX={},%
  AffNormale=false,%
  CouleurNormale=black,%
  Style=histo%
}
\NewDocumentCommand\TracerHistoBinomiale{ O{} D<>{phi} m m }{%
  \restoreKV[tkzHistoBinom]%
  \setKV[tkzHistoBinom]{#1}%
  \def\tkzGraphBinomN{#3}%
  \def\tkzGraphBinomP{#4}%
  % bornes d'affichage
  \IfStrEq{\tkzGraphBinomXminmax}{}%
    {%
      \xdef\tkzGraphBinomXmin{0}%
      \xdef\tkzGraphBinomXmax{\tkzGraphBinomN}%
    }%
    {%
      \StrCut{\tkzGraphBinomXminmax}{-}{\tkzGraphBinomXmin}{\tkzGraphBinomXmax}%
      \IfStrEq{\tkzGraphBinomXmin}{*}{\xdef\tkzGraphBinomXmin{0}}{}%
      \IfStrEq{\tkzGraphBinomXmax}{*}{\xdef\tkzGraphBinomXmax{\tkzGraphBinomN}}{}%
    }%
  % bornes de coloriage
  \IfStrEq{\tkzGraphBinomPlage}{}%
    {}%
    {%
      \StrCut{\tkzGraphBinomPlage}{-}{\tkzGraphBinomColorMin}{\tkzGraphBinomColorMax}%
      \IfStrEq{\tkzGraphBinomColorMin}{*}{\xdef\tkzGraphBinomColorMin{\tkzGraphBinomXmin}}{}%
      \IfStrEq{\tkzGraphBinomColorMax}{*}{\xdef\tkzGraphBinomColorMax{\tkzGraphBinomXmax}}{}%
    }%
  % coloriage éventuel
  \IfStrEq{\tkzGraphBinomPlage}{}%
    {}%
    {%
      \xintFor* ##1 in {\xintSeq{\tkzGraphBinomColorMin}{\tkzGraphBinomColorMax}}\do{%
        \xdef\tkztmpYYY{\xintfloateval{binomial(\tkzGraphBinomN,##1)*(\tkzGraphBinomP)^(##1)*(1-(\tkzGraphBinomP))^((\tkzGraphBinomN)-(##1))}}%
        \IfStrEq{\tkzGraphBinomStyle}{batons}%
        {%
          \draw[pflbarresprobas,\tkzGraphBimomColPlage] ({##1},{\pflymin}) -- ({##1},{\tkztmpYYY-\pflymin}) ;
        }%
        {%
          \draw[draw=none,fill=\tkzGraphBimomColPlage,fill opacity=0.5] ({##1-0.5},{\pflymin}) rectangle++ (1,{\tkztmpYYY-\pflymin}) ;
        }%
      }%
    }%
  % tracé
  \xintFor* ##1 in {\xintSeq{\tkzGraphBinomXmin}{\tkzGraphBinomXmax}}\do{%
    \xdef\tkztmpYYY{\xintfloateval{binomial(\tkzGraphBinomN,##1)*(\tkzGraphBinomP)^(##1)*(1-(\tkzGraphBinomP))^((\tkzGraphBinomN)-(##1))}}%
    \IfStrEq{\tkzGraphBinomStyle}{batons}%
    {%
      \IfStrEq{\tkzGraphBinomPlage}{}%
        {%
          \draw[pflbarresprobas,\tkzGraphBinomColTraits] ({##1},{\pflymin}) -- ({##1},{\tkztmpYYY-\pflymin}) ;
        }%
        {%
          \xintifboolexpr{\tkzGraphBinomColorMin <= ##1 <= \tkzGraphBinomColorMax}%
            {}%
            {%
              \draw[pflbarresprobas,\tkzGraphBinomColTraits] ({##1},{\pflymin}) -- ({##1},{\tkztmpYYY-\pflymin}) ;
            }%
        }%
    }%
    {%
      \draw[pfltrait,\tkzGraphBinomColTraits] ({##1-0.5},{\pflymin}) rectangle++ (1,{\tkztmpYYY-\pflymin}) ;
    }%
  }%
  % approximation normale
  \ifboolKV[tkzHistoBinom]{AffNormale}%
    {%
      \xdef\tkzMinNormHistoBinom{\xintfloateval{\tkzGraphBinomXmin-0.5}}%
      \xdef\tkzMaxNormHistoBinom{\xintfloateval{\tkzGraphBinomXmax+0.5}}%
      \xdef\tkzEsperNorm{\xintfloateval{(#3)*(#4)}}%
      \xdef\tkzVarNorm{\xintfloateval{sqrt((#3)*(#4)*(1-(#4)))}}%
      \DefinirLoiNormale[Trace,Couleur=\tkzGraphBinomColNorm,pflcourbe,%
        Debut=\tkzMinNormHistoBinom,Fin=\tkzMaxNormHistoBinom]%
        <#2>{\tkzEsperNorm}{\tkzVarNorm}%
    }%
    {}%
}
\NewCommandCopy\TracerLoiBinomiale\TracerHistoBinomiale

%\makeatother

\endinput