Simplifying repetitive drawings and nodes placing

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












How to apply the following code, from the answer to this question (which gives the first drawing) to draw the second and third drawings



documentclassbeamer
beamertemplatenavigationsymbolsempty
usepackagetikz
usepackagepgfplots
usetikzlibrarypatterns
begindocument
beginframe[t]
frametitle
hspace -1cm
begintikzpicture[scale=.7, transform shape,linecolor/.style=ultra thick, green!40!black,dotline/.style=thin, black, loosely dotted,
point/.style=circle, draw, red, fill=red, scale=0.4,
cercle/.style=circle,draw,scale=.5, red,thick, fill=white,inner sep=6pt
]
pgfmathsetmacroincrmnt.6

%draw the axes of the left graph
draw [thick,-latex](-.3,0) -- (5,0);
draw [thick,-latex](0,-.3) -- (0,8);

%draw the graph itself
foreach y in 1,...,12draw [linecolor] (0,incrmnt*y) node (yhl) +(0:.15cm) -- +(180:.15cm) node [left] y/12;
draw [dotline] (0,incrmnt*y) -- +(0:8*incrmnt);
foreach x in 1,...,7draw [linecolor] (incrmnt*x,.15) node [ ] -- (incrmnt*x,-.15) node [below] x ;

% left graph
beginscope[every node/.style=circle, draw, solid, red, fill=red, scale=0.4]
draw [linecolor] (incrmnt*1,incrmnt*1) node -- (incrmnt,.15);
draw [linecolor] (incrmnt*2,incrmnt*2) node-- (incrmnt*2,.15);
draw [linecolor] (incrmnt*3,incrmnt*2) node -- (incrmnt*3,.15);
draw [linecolor] (incrmnt*4,incrmnt*2) node -- (incrmnt*4,.15);
draw [linecolor] (incrmnt*5,incrmnt*2) node -- (incrmnt*5,.15);
draw [linecolor] (incrmnt*6,incrmnt*2) node -- (incrmnt*6,.15);
draw [linecolor] (incrmnt*7,incrmnt*1) node -- (incrmnt*7,.15);
endscope

%do the same with the second right graph, plot the same axis by a simple 8cm translation
beginscope[xshift=8cm]
draw [thick,-latex](-2,0)node [below right] $-infty$ -- (6,0);
draw [thick,-latex](0,-.3) -- (0,8);
foreach y in 1,...,12draw [linecolor] (0,incrmnt*y) +(0:.15cm) -- +(180:.15cm) node [left] y/12;
draw [dotline] (0,incrmnt*y) -- +(0:10*incrmnt);
foreach x in 1,...,7draw [linecolor] (incrmnt*x,.15) -- (incrmnt*x,-.15) node [below] x;

% right graph
draw [thick, black] (incrmnt*9,0) node [below] $infty$ --+(0,incrmnt*13);
foreach x in 1,...,6draw[ultra thick, blue](incrmnt*x,incrmnt*(2*x-1))node[point]--+(incrmnt,0)node[cercle];
node[cercle] at(incrmnt,0);
draw[ultra thick, blue](incrmnt*7,incrmnt*12)node[point]--+(incrmnt*2,0);
endscope
endtikzpicture
endframe
enddocument


enter image description here



enter image description here



enter image description here










share|improve this question

























    up vote
    1
    down vote

    favorite












    How to apply the following code, from the answer to this question (which gives the first drawing) to draw the second and third drawings



    documentclassbeamer
    beamertemplatenavigationsymbolsempty
    usepackagetikz
    usepackagepgfplots
    usetikzlibrarypatterns
    begindocument
    beginframe[t]
    frametitle
    hspace -1cm
    begintikzpicture[scale=.7, transform shape,linecolor/.style=ultra thick, green!40!black,dotline/.style=thin, black, loosely dotted,
    point/.style=circle, draw, red, fill=red, scale=0.4,
    cercle/.style=circle,draw,scale=.5, red,thick, fill=white,inner sep=6pt
    ]
    pgfmathsetmacroincrmnt.6

    %draw the axes of the left graph
    draw [thick,-latex](-.3,0) -- (5,0);
    draw [thick,-latex](0,-.3) -- (0,8);

    %draw the graph itself
    foreach y in 1,...,12draw [linecolor] (0,incrmnt*y) node (yhl) +(0:.15cm) -- +(180:.15cm) node [left] y/12;
    draw [dotline] (0,incrmnt*y) -- +(0:8*incrmnt);
    foreach x in 1,...,7draw [linecolor] (incrmnt*x,.15) node [ ] -- (incrmnt*x,-.15) node [below] x ;

    % left graph
    beginscope[every node/.style=circle, draw, solid, red, fill=red, scale=0.4]
    draw [linecolor] (incrmnt*1,incrmnt*1) node -- (incrmnt,.15);
    draw [linecolor] (incrmnt*2,incrmnt*2) node-- (incrmnt*2,.15);
    draw [linecolor] (incrmnt*3,incrmnt*2) node -- (incrmnt*3,.15);
    draw [linecolor] (incrmnt*4,incrmnt*2) node -- (incrmnt*4,.15);
    draw [linecolor] (incrmnt*5,incrmnt*2) node -- (incrmnt*5,.15);
    draw [linecolor] (incrmnt*6,incrmnt*2) node -- (incrmnt*6,.15);
    draw [linecolor] (incrmnt*7,incrmnt*1) node -- (incrmnt*7,.15);
    endscope

    %do the same with the second right graph, plot the same axis by a simple 8cm translation
    beginscope[xshift=8cm]
    draw [thick,-latex](-2,0)node [below right] $-infty$ -- (6,0);
    draw [thick,-latex](0,-.3) -- (0,8);
    foreach y in 1,...,12draw [linecolor] (0,incrmnt*y) +(0:.15cm) -- +(180:.15cm) node [left] y/12;
    draw [dotline] (0,incrmnt*y) -- +(0:10*incrmnt);
    foreach x in 1,...,7draw [linecolor] (incrmnt*x,.15) -- (incrmnt*x,-.15) node [below] x;

    % right graph
    draw [thick, black] (incrmnt*9,0) node [below] $infty$ --+(0,incrmnt*13);
    foreach x in 1,...,6draw[ultra thick, blue](incrmnt*x,incrmnt*(2*x-1))node[point]--+(incrmnt,0)node[cercle];
    node[cercle] at(incrmnt,0);
    draw[ultra thick, blue](incrmnt*7,incrmnt*12)node[point]--+(incrmnt*2,0);
    endscope
    endtikzpicture
    endframe
    enddocument


    enter image description here



    enter image description here



    enter image description here










    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      How to apply the following code, from the answer to this question (which gives the first drawing) to draw the second and third drawings



      documentclassbeamer
      beamertemplatenavigationsymbolsempty
      usepackagetikz
      usepackagepgfplots
      usetikzlibrarypatterns
      begindocument
      beginframe[t]
      frametitle
      hspace -1cm
      begintikzpicture[scale=.7, transform shape,linecolor/.style=ultra thick, green!40!black,dotline/.style=thin, black, loosely dotted,
      point/.style=circle, draw, red, fill=red, scale=0.4,
      cercle/.style=circle,draw,scale=.5, red,thick, fill=white,inner sep=6pt
      ]
      pgfmathsetmacroincrmnt.6

      %draw the axes of the left graph
      draw [thick,-latex](-.3,0) -- (5,0);
      draw [thick,-latex](0,-.3) -- (0,8);

      %draw the graph itself
      foreach y in 1,...,12draw [linecolor] (0,incrmnt*y) node (yhl) +(0:.15cm) -- +(180:.15cm) node [left] y/12;
      draw [dotline] (0,incrmnt*y) -- +(0:8*incrmnt);
      foreach x in 1,...,7draw [linecolor] (incrmnt*x,.15) node [ ] -- (incrmnt*x,-.15) node [below] x ;

      % left graph
      beginscope[every node/.style=circle, draw, solid, red, fill=red, scale=0.4]
      draw [linecolor] (incrmnt*1,incrmnt*1) node -- (incrmnt,.15);
      draw [linecolor] (incrmnt*2,incrmnt*2) node-- (incrmnt*2,.15);
      draw [linecolor] (incrmnt*3,incrmnt*2) node -- (incrmnt*3,.15);
      draw [linecolor] (incrmnt*4,incrmnt*2) node -- (incrmnt*4,.15);
      draw [linecolor] (incrmnt*5,incrmnt*2) node -- (incrmnt*5,.15);
      draw [linecolor] (incrmnt*6,incrmnt*2) node -- (incrmnt*6,.15);
      draw [linecolor] (incrmnt*7,incrmnt*1) node -- (incrmnt*7,.15);
      endscope

      %do the same with the second right graph, plot the same axis by a simple 8cm translation
      beginscope[xshift=8cm]
      draw [thick,-latex](-2,0)node [below right] $-infty$ -- (6,0);
      draw [thick,-latex](0,-.3) -- (0,8);
      foreach y in 1,...,12draw [linecolor] (0,incrmnt*y) +(0:.15cm) -- +(180:.15cm) node [left] y/12;
      draw [dotline] (0,incrmnt*y) -- +(0:10*incrmnt);
      foreach x in 1,...,7draw [linecolor] (incrmnt*x,.15) -- (incrmnt*x,-.15) node [below] x;

      % right graph
      draw [thick, black] (incrmnt*9,0) node [below] $infty$ --+(0,incrmnt*13);
      foreach x in 1,...,6draw[ultra thick, blue](incrmnt*x,incrmnt*(2*x-1))node[point]--+(incrmnt,0)node[cercle];
      node[cercle] at(incrmnt,0);
      draw[ultra thick, blue](incrmnt*7,incrmnt*12)node[point]--+(incrmnt*2,0);
      endscope
      endtikzpicture
      endframe
      enddocument


      enter image description here



      enter image description here



      enter image description here










      share|improve this question













      How to apply the following code, from the answer to this question (which gives the first drawing) to draw the second and third drawings



      documentclassbeamer
      beamertemplatenavigationsymbolsempty
      usepackagetikz
      usepackagepgfplots
      usetikzlibrarypatterns
      begindocument
      beginframe[t]
      frametitle
      hspace -1cm
      begintikzpicture[scale=.7, transform shape,linecolor/.style=ultra thick, green!40!black,dotline/.style=thin, black, loosely dotted,
      point/.style=circle, draw, red, fill=red, scale=0.4,
      cercle/.style=circle,draw,scale=.5, red,thick, fill=white,inner sep=6pt
      ]
      pgfmathsetmacroincrmnt.6

      %draw the axes of the left graph
      draw [thick,-latex](-.3,0) -- (5,0);
      draw [thick,-latex](0,-.3) -- (0,8);

      %draw the graph itself
      foreach y in 1,...,12draw [linecolor] (0,incrmnt*y) node (yhl) +(0:.15cm) -- +(180:.15cm) node [left] y/12;
      draw [dotline] (0,incrmnt*y) -- +(0:8*incrmnt);
      foreach x in 1,...,7draw [linecolor] (incrmnt*x,.15) node [ ] -- (incrmnt*x,-.15) node [below] x ;

      % left graph
      beginscope[every node/.style=circle, draw, solid, red, fill=red, scale=0.4]
      draw [linecolor] (incrmnt*1,incrmnt*1) node -- (incrmnt,.15);
      draw [linecolor] (incrmnt*2,incrmnt*2) node-- (incrmnt*2,.15);
      draw [linecolor] (incrmnt*3,incrmnt*2) node -- (incrmnt*3,.15);
      draw [linecolor] (incrmnt*4,incrmnt*2) node -- (incrmnt*4,.15);
      draw [linecolor] (incrmnt*5,incrmnt*2) node -- (incrmnt*5,.15);
      draw [linecolor] (incrmnt*6,incrmnt*2) node -- (incrmnt*6,.15);
      draw [linecolor] (incrmnt*7,incrmnt*1) node -- (incrmnt*7,.15);
      endscope

      %do the same with the second right graph, plot the same axis by a simple 8cm translation
      beginscope[xshift=8cm]
      draw [thick,-latex](-2,0)node [below right] $-infty$ -- (6,0);
      draw [thick,-latex](0,-.3) -- (0,8);
      foreach y in 1,...,12draw [linecolor] (0,incrmnt*y) +(0:.15cm) -- +(180:.15cm) node [left] y/12;
      draw [dotline] (0,incrmnt*y) -- +(0:10*incrmnt);
      foreach x in 1,...,7draw [linecolor] (incrmnt*x,.15) -- (incrmnt*x,-.15) node [below] x;

      % right graph
      draw [thick, black] (incrmnt*9,0) node [below] $infty$ --+(0,incrmnt*13);
      foreach x in 1,...,6draw[ultra thick, blue](incrmnt*x,incrmnt*(2*x-1))node[point]--+(incrmnt,0)node[cercle];
      node[cercle] at(incrmnt,0);
      draw[ultra thick, blue](incrmnt*7,incrmnt*12)node[point]--+(incrmnt*2,0);
      endscope
      endtikzpicture
      endframe
      enddocument


      enter image description here



      enter image description here



      enter image description here







      tikz-pgf foreach






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 2 hours ago









      Hany

      969314




      969314




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          If I had known where the journey will go when I answered your previous question what I knew when I wrote this answer, I would have recommended pgfplots back then. But given that you seem not to like pgfplots, I provide you loops once more. Nevertheless I can't refrain from asking you to at least consider using pgfplots for that. You'd never have to multiply everything by clumsy units and scale factors, not have to deal with loops that draw the plots or add ticks and so on. (And no, sadly I am not willing to just translate the following quickly to pgfplots "for fun".)



          documentclassbeamer
          beamertemplatenavigationsymbolsempty
          usepackagetikz
          usepackagepgfplots
          usetikzlibrarypatterns
          tikzsetlinecolor/.style=ultra thick, green!40!black,dotline/.style=thin, black, loosely dotted,
          point/.style=circle, draw, red, fill=red, scale=0.4,
          cercle/.style=circle,draw,scale=.5, red,thick, fill=white,inner sep=6pt
          begindocument
          beginframe[t]
          frametitleFirst drawing (unchanged)
          begintikzpicture[scale=.7, transform shape]
          pgfmathsetmacroincrmnt.6

          draw [thick,-latex](-.3,0) -- (5,0);
          draw [thick,-latex](0,-.3) -- (0,8);
          draw [thick,-latex](6.,0) -- (14.4,0) coordinate (br);
          draw [thick,-latex](8,-.2) -- (8,8) coordinate(tr);
          foreach X in 1,...,12

          draw [dotline] (0,X*7cm/12) -- ++ (14,0);
          draw [linecolor] (-incrmnt/2,X*7cm/12)node[left]X/12 -- ++ (incrmnt,0)
          (8-incrmnt/2,X*7cm/12)node[left]X/12-- ++ (incrmnt,0);

          foreach X in 1,...,7

          draw[linecolor] (3*X/5,-incrmnt/2) node[below]X -- ++ (0,incrmnt)
          (8+3*X/5,-incrmnt/2) node[below]X -- ++ (0,incrmnt);
          pgfmathtruncatemacrotstabs(X-4)
          ifnumtst=3
          draw[linecolor] (3*X/5,0) -- ++ (0,7/12)
          node[fill,red,circle,inner sep=2pt];
          else
          draw[linecolor] (3*X/5,0) -- ++ (0,14/12)
          node[fill,red,circle,inner sep=2pt];
          fi
          ifnumX=7
          draw[blue,thick] (8+3*X/5,7*(2*X-2)/12)
          node[fill,red,circle,inner sep=2pt] -- ++ (2*7cm/12,0) coordinate(xr);
          else
          draw[blue,thick] (8+3*X/5,7*(2*X-1)/12) node[fill,red,circle,inner sep=2pt]
          -- ++ (1*7cm/12,0) node[circle,fill=white,draw=red,inner sep=2pt];
          fi

          draw (tr-|xr) -- (br-|xr) node[below](ir)$infty$;
          node at (6.5,0 |-ir) $-infty$;
          node[circle,fill=white,draw=red,inner sep=2pt,thick] at (8+3/5,0);
          endtikzpicture
          endframe

          %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

          beginframe[t]
          frametitleSecond drawing: cdf1
          begintikzpicture[scale=.7, transform shape]
          pgfmathsetmacroincrmnt.6

          draw [thick,-latex](-.3,0) -- (5,0);
          draw [thick,-latex](0,-.3) -- (0,8);
          draw [thick,-latex](6.,0) -- (14.4,0) coordinate (br);
          draw [thick,-latex](8,-.2) -- (8,8) coordinate(tr);
          foreach X [evaluate=X as Y using int(3*X)]in 2,4,...,12

          draw [dotline] (0,X*7cm/12) -- ++ (14,0);
          draw [linecolor] (-incrmnt/2,X*7cm/12)node[left]X/36 -- ++ (incrmnt,0)
          (8-incrmnt/2,X*7cm/12)node[left]Y/36-- ++ (incrmnt,0);

          defhs3,5,4,3,2,1
          foreach X in 0,...,5

          draw[linecolor] (3*(X+1)/4,-incrmnt/2) node[below]X -- ++ (0,incrmnt)
          (8+3*(X+1)/4,-incrmnt/2) node[below]X -- ++ (0,incrmnt);
          pgfmathtruncatemacrohhs[X]
          draw[linecolor] (3*(X+1)/4,0) -- ++ (0,7*h/6);
          draw[blue,thick] (8+3*(X+1)/4,7*(2*X+2)/12) node[fill,red,circle,inner sep=2pt]
          -- ++ (3/4,0) node[circle,fill=white,draw=red,inner sep=2pt] (aux);
          ifnumX<5
          draw[cyan,thick] (aux) -- ++ (0,7/6);
          fi


          endtikzpicture
          endframe

          %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

          beginframe[t]
          frametitleThird drawing: cdf2
          begintikzpicture[scale=.7, transform shape]
          pgfmathsetmacroincrmnt.6

          draw [thick,-latex](-.3,0) -- (5,0);
          draw [thick,-latex](0,-.3) -- (0,8);
          draw [thick,-latex](6.,0) -- (14.4,0) coordinate (br);
          draw [thick,-latex](8,-.2) -- (8,8) coordinate(tr);
          foreach X in 1,...,8

          draw [dotline] (0,X*7/8) -- ++ (14,0);
          ifnumX=8
          draw [linecolor] (-incrmnt/2,X*7/8)node[left]1 -- ++ (incrmnt,0)
          (8-incrmnt/2,X*7/8)node[left]1-- ++ (incrmnt,0);
          else
          draw [linecolor] (-incrmnt/2,X*7/8)node[left]X/8 -- ++ (incrmnt,0)
          (8-incrmnt/2,X*7/8)node[left]X/8-- ++ (incrmnt,0);
          fi

          defhs1,3,3,1
          defsumh0
          foreach X in 0,...,3

          draw[linecolor]
          (X+1,-incrmnt/2) node[below]X -- ++ (0,incrmnt)
          (8+X+1,-incrmnt/2) node[below]X -- ++ (0,incrmnt);
          pgfmathtruncatemacrohhs[X]
          pgfmathtruncatemacrooldsumhsumh
          pgfmathtruncatemacrosumhsumh+h
          xdefsumhsumh
          draw[linecolor] (X+1,0) -- ++ (0,7*h/8)
          node[fill,red,circle,inner sep=2pt];
          draw[cyan,latex-latex] (8+X+1,7*oldsumh/8)
          node[circle,fill=white,draw=red,inner sep=2pt]
          -- (8+X+1,7*sumh/8)node[fill,red,circle,inner sep=2pt] (aux)
          node[midway,right,black]$P_(X)$;
          ifnumX=3
          draw[blue,thick] (aux) -- ++ (14/8,0) coordinate (r);
          else
          draw[blue,thick] (aux) -- ++ (7/8,0);
          fi

          draw (r |- 14,8) -- (r|-14,0)node[below]$infty$;
          node at (6.5,0 |-ir) $-infty$;
          endtikzpicture
          endframe
          enddocument


          enter image description here






          share|improve this answer




















          • Thank you very much for your time and effort.
            – Hany
            12 mins ago











          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "85"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f458336%2fsimplifying-repetitive-drawings-and-nodes-placing%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          3
          down vote



          accepted










          If I had known where the journey will go when I answered your previous question what I knew when I wrote this answer, I would have recommended pgfplots back then. But given that you seem not to like pgfplots, I provide you loops once more. Nevertheless I can't refrain from asking you to at least consider using pgfplots for that. You'd never have to multiply everything by clumsy units and scale factors, not have to deal with loops that draw the plots or add ticks and so on. (And no, sadly I am not willing to just translate the following quickly to pgfplots "for fun".)



          documentclassbeamer
          beamertemplatenavigationsymbolsempty
          usepackagetikz
          usepackagepgfplots
          usetikzlibrarypatterns
          tikzsetlinecolor/.style=ultra thick, green!40!black,dotline/.style=thin, black, loosely dotted,
          point/.style=circle, draw, red, fill=red, scale=0.4,
          cercle/.style=circle,draw,scale=.5, red,thick, fill=white,inner sep=6pt
          begindocument
          beginframe[t]
          frametitleFirst drawing (unchanged)
          begintikzpicture[scale=.7, transform shape]
          pgfmathsetmacroincrmnt.6

          draw [thick,-latex](-.3,0) -- (5,0);
          draw [thick,-latex](0,-.3) -- (0,8);
          draw [thick,-latex](6.,0) -- (14.4,0) coordinate (br);
          draw [thick,-latex](8,-.2) -- (8,8) coordinate(tr);
          foreach X in 1,...,12

          draw [dotline] (0,X*7cm/12) -- ++ (14,0);
          draw [linecolor] (-incrmnt/2,X*7cm/12)node[left]X/12 -- ++ (incrmnt,0)
          (8-incrmnt/2,X*7cm/12)node[left]X/12-- ++ (incrmnt,0);

          foreach X in 1,...,7

          draw[linecolor] (3*X/5,-incrmnt/2) node[below]X -- ++ (0,incrmnt)
          (8+3*X/5,-incrmnt/2) node[below]X -- ++ (0,incrmnt);
          pgfmathtruncatemacrotstabs(X-4)
          ifnumtst=3
          draw[linecolor] (3*X/5,0) -- ++ (0,7/12)
          node[fill,red,circle,inner sep=2pt];
          else
          draw[linecolor] (3*X/5,0) -- ++ (0,14/12)
          node[fill,red,circle,inner sep=2pt];
          fi
          ifnumX=7
          draw[blue,thick] (8+3*X/5,7*(2*X-2)/12)
          node[fill,red,circle,inner sep=2pt] -- ++ (2*7cm/12,0) coordinate(xr);
          else
          draw[blue,thick] (8+3*X/5,7*(2*X-1)/12) node[fill,red,circle,inner sep=2pt]
          -- ++ (1*7cm/12,0) node[circle,fill=white,draw=red,inner sep=2pt];
          fi

          draw (tr-|xr) -- (br-|xr) node[below](ir)$infty$;
          node at (6.5,0 |-ir) $-infty$;
          node[circle,fill=white,draw=red,inner sep=2pt,thick] at (8+3/5,0);
          endtikzpicture
          endframe

          %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

          beginframe[t]
          frametitleSecond drawing: cdf1
          begintikzpicture[scale=.7, transform shape]
          pgfmathsetmacroincrmnt.6

          draw [thick,-latex](-.3,0) -- (5,0);
          draw [thick,-latex](0,-.3) -- (0,8);
          draw [thick,-latex](6.,0) -- (14.4,0) coordinate (br);
          draw [thick,-latex](8,-.2) -- (8,8) coordinate(tr);
          foreach X [evaluate=X as Y using int(3*X)]in 2,4,...,12

          draw [dotline] (0,X*7cm/12) -- ++ (14,0);
          draw [linecolor] (-incrmnt/2,X*7cm/12)node[left]X/36 -- ++ (incrmnt,0)
          (8-incrmnt/2,X*7cm/12)node[left]Y/36-- ++ (incrmnt,0);

          defhs3,5,4,3,2,1
          foreach X in 0,...,5

          draw[linecolor] (3*(X+1)/4,-incrmnt/2) node[below]X -- ++ (0,incrmnt)
          (8+3*(X+1)/4,-incrmnt/2) node[below]X -- ++ (0,incrmnt);
          pgfmathtruncatemacrohhs[X]
          draw[linecolor] (3*(X+1)/4,0) -- ++ (0,7*h/6);
          draw[blue,thick] (8+3*(X+1)/4,7*(2*X+2)/12) node[fill,red,circle,inner sep=2pt]
          -- ++ (3/4,0) node[circle,fill=white,draw=red,inner sep=2pt] (aux);
          ifnumX<5
          draw[cyan,thick] (aux) -- ++ (0,7/6);
          fi


          endtikzpicture
          endframe

          %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

          beginframe[t]
          frametitleThird drawing: cdf2
          begintikzpicture[scale=.7, transform shape]
          pgfmathsetmacroincrmnt.6

          draw [thick,-latex](-.3,0) -- (5,0);
          draw [thick,-latex](0,-.3) -- (0,8);
          draw [thick,-latex](6.,0) -- (14.4,0) coordinate (br);
          draw [thick,-latex](8,-.2) -- (8,8) coordinate(tr);
          foreach X in 1,...,8

          draw [dotline] (0,X*7/8) -- ++ (14,0);
          ifnumX=8
          draw [linecolor] (-incrmnt/2,X*7/8)node[left]1 -- ++ (incrmnt,0)
          (8-incrmnt/2,X*7/8)node[left]1-- ++ (incrmnt,0);
          else
          draw [linecolor] (-incrmnt/2,X*7/8)node[left]X/8 -- ++ (incrmnt,0)
          (8-incrmnt/2,X*7/8)node[left]X/8-- ++ (incrmnt,0);
          fi

          defhs1,3,3,1
          defsumh0
          foreach X in 0,...,3

          draw[linecolor]
          (X+1,-incrmnt/2) node[below]X -- ++ (0,incrmnt)
          (8+X+1,-incrmnt/2) node[below]X -- ++ (0,incrmnt);
          pgfmathtruncatemacrohhs[X]
          pgfmathtruncatemacrooldsumhsumh
          pgfmathtruncatemacrosumhsumh+h
          xdefsumhsumh
          draw[linecolor] (X+1,0) -- ++ (0,7*h/8)
          node[fill,red,circle,inner sep=2pt];
          draw[cyan,latex-latex] (8+X+1,7*oldsumh/8)
          node[circle,fill=white,draw=red,inner sep=2pt]
          -- (8+X+1,7*sumh/8)node[fill,red,circle,inner sep=2pt] (aux)
          node[midway,right,black]$P_(X)$;
          ifnumX=3
          draw[blue,thick] (aux) -- ++ (14/8,0) coordinate (r);
          else
          draw[blue,thick] (aux) -- ++ (7/8,0);
          fi

          draw (r |- 14,8) -- (r|-14,0)node[below]$infty$;
          node at (6.5,0 |-ir) $-infty$;
          endtikzpicture
          endframe
          enddocument


          enter image description here






          share|improve this answer




















          • Thank you very much for your time and effort.
            – Hany
            12 mins ago















          up vote
          3
          down vote



          accepted










          If I had known where the journey will go when I answered your previous question what I knew when I wrote this answer, I would have recommended pgfplots back then. But given that you seem not to like pgfplots, I provide you loops once more. Nevertheless I can't refrain from asking you to at least consider using pgfplots for that. You'd never have to multiply everything by clumsy units and scale factors, not have to deal with loops that draw the plots or add ticks and so on. (And no, sadly I am not willing to just translate the following quickly to pgfplots "for fun".)



          documentclassbeamer
          beamertemplatenavigationsymbolsempty
          usepackagetikz
          usepackagepgfplots
          usetikzlibrarypatterns
          tikzsetlinecolor/.style=ultra thick, green!40!black,dotline/.style=thin, black, loosely dotted,
          point/.style=circle, draw, red, fill=red, scale=0.4,
          cercle/.style=circle,draw,scale=.5, red,thick, fill=white,inner sep=6pt
          begindocument
          beginframe[t]
          frametitleFirst drawing (unchanged)
          begintikzpicture[scale=.7, transform shape]
          pgfmathsetmacroincrmnt.6

          draw [thick,-latex](-.3,0) -- (5,0);
          draw [thick,-latex](0,-.3) -- (0,8);
          draw [thick,-latex](6.,0) -- (14.4,0) coordinate (br);
          draw [thick,-latex](8,-.2) -- (8,8) coordinate(tr);
          foreach X in 1,...,12

          draw [dotline] (0,X*7cm/12) -- ++ (14,0);
          draw [linecolor] (-incrmnt/2,X*7cm/12)node[left]X/12 -- ++ (incrmnt,0)
          (8-incrmnt/2,X*7cm/12)node[left]X/12-- ++ (incrmnt,0);

          foreach X in 1,...,7

          draw[linecolor] (3*X/5,-incrmnt/2) node[below]X -- ++ (0,incrmnt)
          (8+3*X/5,-incrmnt/2) node[below]X -- ++ (0,incrmnt);
          pgfmathtruncatemacrotstabs(X-4)
          ifnumtst=3
          draw[linecolor] (3*X/5,0) -- ++ (0,7/12)
          node[fill,red,circle,inner sep=2pt];
          else
          draw[linecolor] (3*X/5,0) -- ++ (0,14/12)
          node[fill,red,circle,inner sep=2pt];
          fi
          ifnumX=7
          draw[blue,thick] (8+3*X/5,7*(2*X-2)/12)
          node[fill,red,circle,inner sep=2pt] -- ++ (2*7cm/12,0) coordinate(xr);
          else
          draw[blue,thick] (8+3*X/5,7*(2*X-1)/12) node[fill,red,circle,inner sep=2pt]
          -- ++ (1*7cm/12,0) node[circle,fill=white,draw=red,inner sep=2pt];
          fi

          draw (tr-|xr) -- (br-|xr) node[below](ir)$infty$;
          node at (6.5,0 |-ir) $-infty$;
          node[circle,fill=white,draw=red,inner sep=2pt,thick] at (8+3/5,0);
          endtikzpicture
          endframe

          %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

          beginframe[t]
          frametitleSecond drawing: cdf1
          begintikzpicture[scale=.7, transform shape]
          pgfmathsetmacroincrmnt.6

          draw [thick,-latex](-.3,0) -- (5,0);
          draw [thick,-latex](0,-.3) -- (0,8);
          draw [thick,-latex](6.,0) -- (14.4,0) coordinate (br);
          draw [thick,-latex](8,-.2) -- (8,8) coordinate(tr);
          foreach X [evaluate=X as Y using int(3*X)]in 2,4,...,12

          draw [dotline] (0,X*7cm/12) -- ++ (14,0);
          draw [linecolor] (-incrmnt/2,X*7cm/12)node[left]X/36 -- ++ (incrmnt,0)
          (8-incrmnt/2,X*7cm/12)node[left]Y/36-- ++ (incrmnt,0);

          defhs3,5,4,3,2,1
          foreach X in 0,...,5

          draw[linecolor] (3*(X+1)/4,-incrmnt/2) node[below]X -- ++ (0,incrmnt)
          (8+3*(X+1)/4,-incrmnt/2) node[below]X -- ++ (0,incrmnt);
          pgfmathtruncatemacrohhs[X]
          draw[linecolor] (3*(X+1)/4,0) -- ++ (0,7*h/6);
          draw[blue,thick] (8+3*(X+1)/4,7*(2*X+2)/12) node[fill,red,circle,inner sep=2pt]
          -- ++ (3/4,0) node[circle,fill=white,draw=red,inner sep=2pt] (aux);
          ifnumX<5
          draw[cyan,thick] (aux) -- ++ (0,7/6);
          fi


          endtikzpicture
          endframe

          %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

          beginframe[t]
          frametitleThird drawing: cdf2
          begintikzpicture[scale=.7, transform shape]
          pgfmathsetmacroincrmnt.6

          draw [thick,-latex](-.3,0) -- (5,0);
          draw [thick,-latex](0,-.3) -- (0,8);
          draw [thick,-latex](6.,0) -- (14.4,0) coordinate (br);
          draw [thick,-latex](8,-.2) -- (8,8) coordinate(tr);
          foreach X in 1,...,8

          draw [dotline] (0,X*7/8) -- ++ (14,0);
          ifnumX=8
          draw [linecolor] (-incrmnt/2,X*7/8)node[left]1 -- ++ (incrmnt,0)
          (8-incrmnt/2,X*7/8)node[left]1-- ++ (incrmnt,0);
          else
          draw [linecolor] (-incrmnt/2,X*7/8)node[left]X/8 -- ++ (incrmnt,0)
          (8-incrmnt/2,X*7/8)node[left]X/8-- ++ (incrmnt,0);
          fi

          defhs1,3,3,1
          defsumh0
          foreach X in 0,...,3

          draw[linecolor]
          (X+1,-incrmnt/2) node[below]X -- ++ (0,incrmnt)
          (8+X+1,-incrmnt/2) node[below]X -- ++ (0,incrmnt);
          pgfmathtruncatemacrohhs[X]
          pgfmathtruncatemacrooldsumhsumh
          pgfmathtruncatemacrosumhsumh+h
          xdefsumhsumh
          draw[linecolor] (X+1,0) -- ++ (0,7*h/8)
          node[fill,red,circle,inner sep=2pt];
          draw[cyan,latex-latex] (8+X+1,7*oldsumh/8)
          node[circle,fill=white,draw=red,inner sep=2pt]
          -- (8+X+1,7*sumh/8)node[fill,red,circle,inner sep=2pt] (aux)
          node[midway,right,black]$P_(X)$;
          ifnumX=3
          draw[blue,thick] (aux) -- ++ (14/8,0) coordinate (r);
          else
          draw[blue,thick] (aux) -- ++ (7/8,0);
          fi

          draw (r |- 14,8) -- (r|-14,0)node[below]$infty$;
          node at (6.5,0 |-ir) $-infty$;
          endtikzpicture
          endframe
          enddocument


          enter image description here






          share|improve this answer




















          • Thank you very much for your time and effort.
            – Hany
            12 mins ago













          up vote
          3
          down vote



          accepted







          up vote
          3
          down vote



          accepted






          If I had known where the journey will go when I answered your previous question what I knew when I wrote this answer, I would have recommended pgfplots back then. But given that you seem not to like pgfplots, I provide you loops once more. Nevertheless I can't refrain from asking you to at least consider using pgfplots for that. You'd never have to multiply everything by clumsy units and scale factors, not have to deal with loops that draw the plots or add ticks and so on. (And no, sadly I am not willing to just translate the following quickly to pgfplots "for fun".)



          documentclassbeamer
          beamertemplatenavigationsymbolsempty
          usepackagetikz
          usepackagepgfplots
          usetikzlibrarypatterns
          tikzsetlinecolor/.style=ultra thick, green!40!black,dotline/.style=thin, black, loosely dotted,
          point/.style=circle, draw, red, fill=red, scale=0.4,
          cercle/.style=circle,draw,scale=.5, red,thick, fill=white,inner sep=6pt
          begindocument
          beginframe[t]
          frametitleFirst drawing (unchanged)
          begintikzpicture[scale=.7, transform shape]
          pgfmathsetmacroincrmnt.6

          draw [thick,-latex](-.3,0) -- (5,0);
          draw [thick,-latex](0,-.3) -- (0,8);
          draw [thick,-latex](6.,0) -- (14.4,0) coordinate (br);
          draw [thick,-latex](8,-.2) -- (8,8) coordinate(tr);
          foreach X in 1,...,12

          draw [dotline] (0,X*7cm/12) -- ++ (14,0);
          draw [linecolor] (-incrmnt/2,X*7cm/12)node[left]X/12 -- ++ (incrmnt,0)
          (8-incrmnt/2,X*7cm/12)node[left]X/12-- ++ (incrmnt,0);

          foreach X in 1,...,7

          draw[linecolor] (3*X/5,-incrmnt/2) node[below]X -- ++ (0,incrmnt)
          (8+3*X/5,-incrmnt/2) node[below]X -- ++ (0,incrmnt);
          pgfmathtruncatemacrotstabs(X-4)
          ifnumtst=3
          draw[linecolor] (3*X/5,0) -- ++ (0,7/12)
          node[fill,red,circle,inner sep=2pt];
          else
          draw[linecolor] (3*X/5,0) -- ++ (0,14/12)
          node[fill,red,circle,inner sep=2pt];
          fi
          ifnumX=7
          draw[blue,thick] (8+3*X/5,7*(2*X-2)/12)
          node[fill,red,circle,inner sep=2pt] -- ++ (2*7cm/12,0) coordinate(xr);
          else
          draw[blue,thick] (8+3*X/5,7*(2*X-1)/12) node[fill,red,circle,inner sep=2pt]
          -- ++ (1*7cm/12,0) node[circle,fill=white,draw=red,inner sep=2pt];
          fi

          draw (tr-|xr) -- (br-|xr) node[below](ir)$infty$;
          node at (6.5,0 |-ir) $-infty$;
          node[circle,fill=white,draw=red,inner sep=2pt,thick] at (8+3/5,0);
          endtikzpicture
          endframe

          %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

          beginframe[t]
          frametitleSecond drawing: cdf1
          begintikzpicture[scale=.7, transform shape]
          pgfmathsetmacroincrmnt.6

          draw [thick,-latex](-.3,0) -- (5,0);
          draw [thick,-latex](0,-.3) -- (0,8);
          draw [thick,-latex](6.,0) -- (14.4,0) coordinate (br);
          draw [thick,-latex](8,-.2) -- (8,8) coordinate(tr);
          foreach X [evaluate=X as Y using int(3*X)]in 2,4,...,12

          draw [dotline] (0,X*7cm/12) -- ++ (14,0);
          draw [linecolor] (-incrmnt/2,X*7cm/12)node[left]X/36 -- ++ (incrmnt,0)
          (8-incrmnt/2,X*7cm/12)node[left]Y/36-- ++ (incrmnt,0);

          defhs3,5,4,3,2,1
          foreach X in 0,...,5

          draw[linecolor] (3*(X+1)/4,-incrmnt/2) node[below]X -- ++ (0,incrmnt)
          (8+3*(X+1)/4,-incrmnt/2) node[below]X -- ++ (0,incrmnt);
          pgfmathtruncatemacrohhs[X]
          draw[linecolor] (3*(X+1)/4,0) -- ++ (0,7*h/6);
          draw[blue,thick] (8+3*(X+1)/4,7*(2*X+2)/12) node[fill,red,circle,inner sep=2pt]
          -- ++ (3/4,0) node[circle,fill=white,draw=red,inner sep=2pt] (aux);
          ifnumX<5
          draw[cyan,thick] (aux) -- ++ (0,7/6);
          fi


          endtikzpicture
          endframe

          %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

          beginframe[t]
          frametitleThird drawing: cdf2
          begintikzpicture[scale=.7, transform shape]
          pgfmathsetmacroincrmnt.6

          draw [thick,-latex](-.3,0) -- (5,0);
          draw [thick,-latex](0,-.3) -- (0,8);
          draw [thick,-latex](6.,0) -- (14.4,0) coordinate (br);
          draw [thick,-latex](8,-.2) -- (8,8) coordinate(tr);
          foreach X in 1,...,8

          draw [dotline] (0,X*7/8) -- ++ (14,0);
          ifnumX=8
          draw [linecolor] (-incrmnt/2,X*7/8)node[left]1 -- ++ (incrmnt,0)
          (8-incrmnt/2,X*7/8)node[left]1-- ++ (incrmnt,0);
          else
          draw [linecolor] (-incrmnt/2,X*7/8)node[left]X/8 -- ++ (incrmnt,0)
          (8-incrmnt/2,X*7/8)node[left]X/8-- ++ (incrmnt,0);
          fi

          defhs1,3,3,1
          defsumh0
          foreach X in 0,...,3

          draw[linecolor]
          (X+1,-incrmnt/2) node[below]X -- ++ (0,incrmnt)
          (8+X+1,-incrmnt/2) node[below]X -- ++ (0,incrmnt);
          pgfmathtruncatemacrohhs[X]
          pgfmathtruncatemacrooldsumhsumh
          pgfmathtruncatemacrosumhsumh+h
          xdefsumhsumh
          draw[linecolor] (X+1,0) -- ++ (0,7*h/8)
          node[fill,red,circle,inner sep=2pt];
          draw[cyan,latex-latex] (8+X+1,7*oldsumh/8)
          node[circle,fill=white,draw=red,inner sep=2pt]
          -- (8+X+1,7*sumh/8)node[fill,red,circle,inner sep=2pt] (aux)
          node[midway,right,black]$P_(X)$;
          ifnumX=3
          draw[blue,thick] (aux) -- ++ (14/8,0) coordinate (r);
          else
          draw[blue,thick] (aux) -- ++ (7/8,0);
          fi

          draw (r |- 14,8) -- (r|-14,0)node[below]$infty$;
          node at (6.5,0 |-ir) $-infty$;
          endtikzpicture
          endframe
          enddocument


          enter image description here






          share|improve this answer












          If I had known where the journey will go when I answered your previous question what I knew when I wrote this answer, I would have recommended pgfplots back then. But given that you seem not to like pgfplots, I provide you loops once more. Nevertheless I can't refrain from asking you to at least consider using pgfplots for that. You'd never have to multiply everything by clumsy units and scale factors, not have to deal with loops that draw the plots or add ticks and so on. (And no, sadly I am not willing to just translate the following quickly to pgfplots "for fun".)



          documentclassbeamer
          beamertemplatenavigationsymbolsempty
          usepackagetikz
          usepackagepgfplots
          usetikzlibrarypatterns
          tikzsetlinecolor/.style=ultra thick, green!40!black,dotline/.style=thin, black, loosely dotted,
          point/.style=circle, draw, red, fill=red, scale=0.4,
          cercle/.style=circle,draw,scale=.5, red,thick, fill=white,inner sep=6pt
          begindocument
          beginframe[t]
          frametitleFirst drawing (unchanged)
          begintikzpicture[scale=.7, transform shape]
          pgfmathsetmacroincrmnt.6

          draw [thick,-latex](-.3,0) -- (5,0);
          draw [thick,-latex](0,-.3) -- (0,8);
          draw [thick,-latex](6.,0) -- (14.4,0) coordinate (br);
          draw [thick,-latex](8,-.2) -- (8,8) coordinate(tr);
          foreach X in 1,...,12

          draw [dotline] (0,X*7cm/12) -- ++ (14,0);
          draw [linecolor] (-incrmnt/2,X*7cm/12)node[left]X/12 -- ++ (incrmnt,0)
          (8-incrmnt/2,X*7cm/12)node[left]X/12-- ++ (incrmnt,0);

          foreach X in 1,...,7

          draw[linecolor] (3*X/5,-incrmnt/2) node[below]X -- ++ (0,incrmnt)
          (8+3*X/5,-incrmnt/2) node[below]X -- ++ (0,incrmnt);
          pgfmathtruncatemacrotstabs(X-4)
          ifnumtst=3
          draw[linecolor] (3*X/5,0) -- ++ (0,7/12)
          node[fill,red,circle,inner sep=2pt];
          else
          draw[linecolor] (3*X/5,0) -- ++ (0,14/12)
          node[fill,red,circle,inner sep=2pt];
          fi
          ifnumX=7
          draw[blue,thick] (8+3*X/5,7*(2*X-2)/12)
          node[fill,red,circle,inner sep=2pt] -- ++ (2*7cm/12,0) coordinate(xr);
          else
          draw[blue,thick] (8+3*X/5,7*(2*X-1)/12) node[fill,red,circle,inner sep=2pt]
          -- ++ (1*7cm/12,0) node[circle,fill=white,draw=red,inner sep=2pt];
          fi

          draw (tr-|xr) -- (br-|xr) node[below](ir)$infty$;
          node at (6.5,0 |-ir) $-infty$;
          node[circle,fill=white,draw=red,inner sep=2pt,thick] at (8+3/5,0);
          endtikzpicture
          endframe

          %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

          beginframe[t]
          frametitleSecond drawing: cdf1
          begintikzpicture[scale=.7, transform shape]
          pgfmathsetmacroincrmnt.6

          draw [thick,-latex](-.3,0) -- (5,0);
          draw [thick,-latex](0,-.3) -- (0,8);
          draw [thick,-latex](6.,0) -- (14.4,0) coordinate (br);
          draw [thick,-latex](8,-.2) -- (8,8) coordinate(tr);
          foreach X [evaluate=X as Y using int(3*X)]in 2,4,...,12

          draw [dotline] (0,X*7cm/12) -- ++ (14,0);
          draw [linecolor] (-incrmnt/2,X*7cm/12)node[left]X/36 -- ++ (incrmnt,0)
          (8-incrmnt/2,X*7cm/12)node[left]Y/36-- ++ (incrmnt,0);

          defhs3,5,4,3,2,1
          foreach X in 0,...,5

          draw[linecolor] (3*(X+1)/4,-incrmnt/2) node[below]X -- ++ (0,incrmnt)
          (8+3*(X+1)/4,-incrmnt/2) node[below]X -- ++ (0,incrmnt);
          pgfmathtruncatemacrohhs[X]
          draw[linecolor] (3*(X+1)/4,0) -- ++ (0,7*h/6);
          draw[blue,thick] (8+3*(X+1)/4,7*(2*X+2)/12) node[fill,red,circle,inner sep=2pt]
          -- ++ (3/4,0) node[circle,fill=white,draw=red,inner sep=2pt] (aux);
          ifnumX<5
          draw[cyan,thick] (aux) -- ++ (0,7/6);
          fi


          endtikzpicture
          endframe

          %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

          beginframe[t]
          frametitleThird drawing: cdf2
          begintikzpicture[scale=.7, transform shape]
          pgfmathsetmacroincrmnt.6

          draw [thick,-latex](-.3,0) -- (5,0);
          draw [thick,-latex](0,-.3) -- (0,8);
          draw [thick,-latex](6.,0) -- (14.4,0) coordinate (br);
          draw [thick,-latex](8,-.2) -- (8,8) coordinate(tr);
          foreach X in 1,...,8

          draw [dotline] (0,X*7/8) -- ++ (14,0);
          ifnumX=8
          draw [linecolor] (-incrmnt/2,X*7/8)node[left]1 -- ++ (incrmnt,0)
          (8-incrmnt/2,X*7/8)node[left]1-- ++ (incrmnt,0);
          else
          draw [linecolor] (-incrmnt/2,X*7/8)node[left]X/8 -- ++ (incrmnt,0)
          (8-incrmnt/2,X*7/8)node[left]X/8-- ++ (incrmnt,0);
          fi

          defhs1,3,3,1
          defsumh0
          foreach X in 0,...,3

          draw[linecolor]
          (X+1,-incrmnt/2) node[below]X -- ++ (0,incrmnt)
          (8+X+1,-incrmnt/2) node[below]X -- ++ (0,incrmnt);
          pgfmathtruncatemacrohhs[X]
          pgfmathtruncatemacrooldsumhsumh
          pgfmathtruncatemacrosumhsumh+h
          xdefsumhsumh
          draw[linecolor] (X+1,0) -- ++ (0,7*h/8)
          node[fill,red,circle,inner sep=2pt];
          draw[cyan,latex-latex] (8+X+1,7*oldsumh/8)
          node[circle,fill=white,draw=red,inner sep=2pt]
          -- (8+X+1,7*sumh/8)node[fill,red,circle,inner sep=2pt] (aux)
          node[midway,right,black]$P_(X)$;
          ifnumX=3
          draw[blue,thick] (aux) -- ++ (14/8,0) coordinate (r);
          else
          draw[blue,thick] (aux) -- ++ (7/8,0);
          fi

          draw (r |- 14,8) -- (r|-14,0)node[below]$infty$;
          node at (6.5,0 |-ir) $-infty$;
          endtikzpicture
          endframe
          enddocument


          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 1 hour ago









          marmot

          71.5k476152




          71.5k476152











          • Thank you very much for your time and effort.
            – Hany
            12 mins ago

















          • Thank you very much for your time and effort.
            – Hany
            12 mins ago
















          Thank you very much for your time and effort.
          – Hany
          12 mins ago





          Thank you very much for your time and effort.
          – Hany
          12 mins ago


















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f458336%2fsimplifying-repetitive-drawings-and-nodes-placing%23new-answer', 'question_page');

          );

          Post as a guest













































































          Comments

          Popular posts from this blog

          What does second last employer means? [closed]

          List of Gilmore Girls characters

          One-line joke