How can I make a curved graph in Tikz and vertical lines from the x-axis to that graph?









up vote
2
down vote

favorite












I am basically trying to make this figure in Tikz only better, but I can't figure out how to make the vertical lines from the x-axis to the graphs M(x). The function is M(x)=−1/2·q·x^2+1/2·q·L·x, where the values of q and L doesn't matter in the first place.



(The figure is made in Maple 2018. It hints at the mistakes made in the vertical lines.)



A curve with the maximum point at Mmax










share|improve this question



















  • 1




    Welcome to TeX.SX! What have you tried so far? Please add your attempt as a compilable document to the question so that others can use it as a base.
    – siracusa
    Nov 10 at 15:04










  • Use a ycomb plot.
    – Torbjørn T.
    Nov 10 at 15:09














up vote
2
down vote

favorite












I am basically trying to make this figure in Tikz only better, but I can't figure out how to make the vertical lines from the x-axis to the graphs M(x). The function is M(x)=−1/2·q·x^2+1/2·q·L·x, where the values of q and L doesn't matter in the first place.



(The figure is made in Maple 2018. It hints at the mistakes made in the vertical lines.)



A curve with the maximum point at Mmax










share|improve this question



















  • 1




    Welcome to TeX.SX! What have you tried so far? Please add your attempt as a compilable document to the question so that others can use it as a base.
    – siracusa
    Nov 10 at 15:04










  • Use a ycomb plot.
    – Torbjørn T.
    Nov 10 at 15:09












up vote
2
down vote

favorite









up vote
2
down vote

favorite











I am basically trying to make this figure in Tikz only better, but I can't figure out how to make the vertical lines from the x-axis to the graphs M(x). The function is M(x)=−1/2·q·x^2+1/2·q·L·x, where the values of q and L doesn't matter in the first place.



(The figure is made in Maple 2018. It hints at the mistakes made in the vertical lines.)



A curve with the maximum point at Mmax










share|improve this question















I am basically trying to make this figure in Tikz only better, but I can't figure out how to make the vertical lines from the x-axis to the graphs M(x). The function is M(x)=−1/2·q·x^2+1/2·q·L·x, where the values of q and L doesn't matter in the first place.



(The figure is made in Maple 2018. It hints at the mistakes made in the vertical lines.)



A curve with the maximum point at Mmax







tikz-pgf graphs vertical addlines






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 10 at 23:12









Peter Mortensen

52736




52736










asked Nov 10 at 14:56









Mikkel AAU

162




162







  • 1




    Welcome to TeX.SX! What have you tried so far? Please add your attempt as a compilable document to the question so that others can use it as a base.
    – siracusa
    Nov 10 at 15:04










  • Use a ycomb plot.
    – Torbjørn T.
    Nov 10 at 15:09












  • 1




    Welcome to TeX.SX! What have you tried so far? Please add your attempt as a compilable document to the question so that others can use it as a base.
    – siracusa
    Nov 10 at 15:04










  • Use a ycomb plot.
    – Torbjørn T.
    Nov 10 at 15:09







1




1




Welcome to TeX.SX! What have you tried so far? Please add your attempt as a compilable document to the question so that others can use it as a base.
– siracusa
Nov 10 at 15:04




Welcome to TeX.SX! What have you tried so far? Please add your attempt as a compilable document to the question so that others can use it as a base.
– siracusa
Nov 10 at 15:04












Use a ycomb plot.
– Torbjørn T.
Nov 10 at 15:09




Use a ycomb plot.
– Torbjørn T.
Nov 10 at 15:09










4 Answers
4






active

oldest

votes

















up vote
3
down vote



accepted










This is a very 'hacky' solution, and I'm sure some people will be able to give you a more elegant answer, but this definitely works!



I also like it because it's been a very broadly applicable technique for me (especially using intersections).



MWE:



documentclassarticle
usepackageamsmath
usepackagetikz
usetikzlibrarycalc,intersections

begindocument
begintikzpicture
draw[<->] (0,6) node[above]M--(0,0)--(9,0)node[right]L;
draw[name path = C] (0,0) .. controls (3,6) and (5,6) .. (8,0) node[pos = 0.5, above] $M_max = dfrac18 cdot q cdot L^2$;

foreach i in 0,0.5,...,8
draw[draw opacity = 0, name path = L] (i,0)--(i,6);
draw [name intersections =of = L and C] let p1 = (intersection-1) in (x1,y1)--(x1,0);

endtikzpicture
enddocument


Output:



enter image description here



PS: If you need the curve to look differently, just edit the code for draw[name path = C].... For instance, by changing it to:



draw[name path = C] (0,0) .. controls (2,4) and (6,4) .. (8,0) node[pos = 0.5, above] $M_max = dfrac18 cdot q cdot L^2$;


you get this (which is closer to your original image). I illustrated this just in case you wanted to see a sample of how to draw curves. :)



enter image description here






share|improve this answer





























    up vote
    6
    down vote













    As I mention in a comment, a ycomb plot can be used for this. Here are two examples, the first a modified version of marmot's code, the second a more verbose (and probably more complicated than it needs to be) version using pgfplots.



    enter image description here



    documentclass[border=5mm]standalone
    usepackagepgfplots
    pgfplotssetcompat=1.3
    begindocument
    begintikzpicture[
    declare function=
    M(x) = 4-(x-4)*(x-4)/4;

    ]
    draw[latex-latex] (0,6) node[left] $mathbfM$ |- (8.5,0) node[below]
    $mathbfL$;
    draw[thick] plot[variable=x,domain=0:8,smooth] (x,M(x));
    draw[thick] plot[variable=x,domain=0:8,ycomb] (x,M(x));
    endtikzpicture

    begintikzpicture
    beginaxis[
    declare function=
    t = 2;
    mid = 5;
    d=4.5;
    M(x) = -(x-mid)^2*(t/d^2) + t;
    ,
    axis lines=middle,
    xtick=empty, ytick=empty,
    ylabel=$M$, xlabel=$L$,
    enlarge x limits,
    enlarge y limits=value=0.5,upper,
    domain=mid-d:mid+d
    ]

    addplot [thick] M(x) node[midway, above] $M_max = frac18 qL$;
    addplot [ycomb, samples=15] M(x);
    endaxis
    endtikzpicture

    enddocument





    share|improve this answer



























      up vote
      5
      down vote













      Here is one more possibility: use a pattern. And if you use clip, as suggested by @nidhin, I'd use a grid rather than a foreach loop. In fact, if you use foreach, since the function is known, you do not need clip.



      documentclass[tikz,border=3.14mm]standalone
      usetikzlibrarypatterns
      usepackageamsmath
      begindocument
      begintikzpicture
      draw[latex-latex] (0,6) node[left] $boldsymbolM$ |- (8.5,0) node[below]
      $boldsymbolL$;
      draw[thick,pattern=vertical lines] plot[variable=x,domain=0:8,smooth] (x,4-(x-4)*(x-4)/4);
      endtikzpicture

      begintikzpicture
      draw[latex-latex] (0,6) node[left] $boldsymbolM$ |- (8.5,0) node[below]
      $boldsymbolL$;
      draw[thick] plot[variable=x,domain=0:8,smooth] (x,4-(x-4)*(x-4)/4);
      clip plot[variable=x,domain=0:8,smooth] (x,4-(x-4)*(x-4)/4);
      draw (0,0) grid[xstep=1cm,ystep=6cm] (8,5);
      endtikzpicture
      enddocument


      enter image description here






      share|improve this answer



























        up vote
        4
        down vote













        Using clip



        documentclassstandalone
        usepackageamsmath
        usepackagetikz
        begindocument
        begintikzpicture[>=latex]
        draw(4,5) node $M_max = dfrac18 cdot q cdot L^2$;
        draw[<->] (0,6) node[above]M--(0,0)--(9,0)node[right]L;
        draw[clip] (0,0) .. controls (3,6) and (5,6) .. (8,0) --cycle;
        foreach i in 0,0.5,...,8
        draw (i,0) -- ++ (0,10);
        endtikzpicture
        enddocument


        enter image description here






        share|improve this answer




















          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%2f459323%2fhow-can-i-make-a-curved-graph-in-tikz-and-vertical-lines-from-the-x-axis-to-that%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          4 Answers
          4






          active

          oldest

          votes








          4 Answers
          4






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          3
          down vote



          accepted










          This is a very 'hacky' solution, and I'm sure some people will be able to give you a more elegant answer, but this definitely works!



          I also like it because it's been a very broadly applicable technique for me (especially using intersections).



          MWE:



          documentclassarticle
          usepackageamsmath
          usepackagetikz
          usetikzlibrarycalc,intersections

          begindocument
          begintikzpicture
          draw[<->] (0,6) node[above]M--(0,0)--(9,0)node[right]L;
          draw[name path = C] (0,0) .. controls (3,6) and (5,6) .. (8,0) node[pos = 0.5, above] $M_max = dfrac18 cdot q cdot L^2$;

          foreach i in 0,0.5,...,8
          draw[draw opacity = 0, name path = L] (i,0)--(i,6);
          draw [name intersections =of = L and C] let p1 = (intersection-1) in (x1,y1)--(x1,0);

          endtikzpicture
          enddocument


          Output:



          enter image description here



          PS: If you need the curve to look differently, just edit the code for draw[name path = C].... For instance, by changing it to:



          draw[name path = C] (0,0) .. controls (2,4) and (6,4) .. (8,0) node[pos = 0.5, above] $M_max = dfrac18 cdot q cdot L^2$;


          you get this (which is closer to your original image). I illustrated this just in case you wanted to see a sample of how to draw curves. :)



          enter image description here






          share|improve this answer


























            up vote
            3
            down vote



            accepted










            This is a very 'hacky' solution, and I'm sure some people will be able to give you a more elegant answer, but this definitely works!



            I also like it because it's been a very broadly applicable technique for me (especially using intersections).



            MWE:



            documentclassarticle
            usepackageamsmath
            usepackagetikz
            usetikzlibrarycalc,intersections

            begindocument
            begintikzpicture
            draw[<->] (0,6) node[above]M--(0,0)--(9,0)node[right]L;
            draw[name path = C] (0,0) .. controls (3,6) and (5,6) .. (8,0) node[pos = 0.5, above] $M_max = dfrac18 cdot q cdot L^2$;

            foreach i in 0,0.5,...,8
            draw[draw opacity = 0, name path = L] (i,0)--(i,6);
            draw [name intersections =of = L and C] let p1 = (intersection-1) in (x1,y1)--(x1,0);

            endtikzpicture
            enddocument


            Output:



            enter image description here



            PS: If you need the curve to look differently, just edit the code for draw[name path = C].... For instance, by changing it to:



            draw[name path = C] (0,0) .. controls (2,4) and (6,4) .. (8,0) node[pos = 0.5, above] $M_max = dfrac18 cdot q cdot L^2$;


            you get this (which is closer to your original image). I illustrated this just in case you wanted to see a sample of how to draw curves. :)



            enter image description here






            share|improve this answer
























              up vote
              3
              down vote



              accepted







              up vote
              3
              down vote



              accepted






              This is a very 'hacky' solution, and I'm sure some people will be able to give you a more elegant answer, but this definitely works!



              I also like it because it's been a very broadly applicable technique for me (especially using intersections).



              MWE:



              documentclassarticle
              usepackageamsmath
              usepackagetikz
              usetikzlibrarycalc,intersections

              begindocument
              begintikzpicture
              draw[<->] (0,6) node[above]M--(0,0)--(9,0)node[right]L;
              draw[name path = C] (0,0) .. controls (3,6) and (5,6) .. (8,0) node[pos = 0.5, above] $M_max = dfrac18 cdot q cdot L^2$;

              foreach i in 0,0.5,...,8
              draw[draw opacity = 0, name path = L] (i,0)--(i,6);
              draw [name intersections =of = L and C] let p1 = (intersection-1) in (x1,y1)--(x1,0);

              endtikzpicture
              enddocument


              Output:



              enter image description here



              PS: If you need the curve to look differently, just edit the code for draw[name path = C].... For instance, by changing it to:



              draw[name path = C] (0,0) .. controls (2,4) and (6,4) .. (8,0) node[pos = 0.5, above] $M_max = dfrac18 cdot q cdot L^2$;


              you get this (which is closer to your original image). I illustrated this just in case you wanted to see a sample of how to draw curves. :)



              enter image description here






              share|improve this answer














              This is a very 'hacky' solution, and I'm sure some people will be able to give you a more elegant answer, but this definitely works!



              I also like it because it's been a very broadly applicable technique for me (especially using intersections).



              MWE:



              documentclassarticle
              usepackageamsmath
              usepackagetikz
              usetikzlibrarycalc,intersections

              begindocument
              begintikzpicture
              draw[<->] (0,6) node[above]M--(0,0)--(9,0)node[right]L;
              draw[name path = C] (0,0) .. controls (3,6) and (5,6) .. (8,0) node[pos = 0.5, above] $M_max = dfrac18 cdot q cdot L^2$;

              foreach i in 0,0.5,...,8
              draw[draw opacity = 0, name path = L] (i,0)--(i,6);
              draw [name intersections =of = L and C] let p1 = (intersection-1) in (x1,y1)--(x1,0);

              endtikzpicture
              enddocument


              Output:



              enter image description here



              PS: If you need the curve to look differently, just edit the code for draw[name path = C].... For instance, by changing it to:



              draw[name path = C] (0,0) .. controls (2,4) and (6,4) .. (8,0) node[pos = 0.5, above] $M_max = dfrac18 cdot q cdot L^2$;


              you get this (which is closer to your original image). I illustrated this just in case you wanted to see a sample of how to draw curves. :)



              enter image description here







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Nov 10 at 15:18

























              answered Nov 10 at 15:12









              Thevesh Theva

              513114




              513114




















                  up vote
                  6
                  down vote













                  As I mention in a comment, a ycomb plot can be used for this. Here are two examples, the first a modified version of marmot's code, the second a more verbose (and probably more complicated than it needs to be) version using pgfplots.



                  enter image description here



                  documentclass[border=5mm]standalone
                  usepackagepgfplots
                  pgfplotssetcompat=1.3
                  begindocument
                  begintikzpicture[
                  declare function=
                  M(x) = 4-(x-4)*(x-4)/4;

                  ]
                  draw[latex-latex] (0,6) node[left] $mathbfM$ |- (8.5,0) node[below]
                  $mathbfL$;
                  draw[thick] plot[variable=x,domain=0:8,smooth] (x,M(x));
                  draw[thick] plot[variable=x,domain=0:8,ycomb] (x,M(x));
                  endtikzpicture

                  begintikzpicture
                  beginaxis[
                  declare function=
                  t = 2;
                  mid = 5;
                  d=4.5;
                  M(x) = -(x-mid)^2*(t/d^2) + t;
                  ,
                  axis lines=middle,
                  xtick=empty, ytick=empty,
                  ylabel=$M$, xlabel=$L$,
                  enlarge x limits,
                  enlarge y limits=value=0.5,upper,
                  domain=mid-d:mid+d
                  ]

                  addplot [thick] M(x) node[midway, above] $M_max = frac18 qL$;
                  addplot [ycomb, samples=15] M(x);
                  endaxis
                  endtikzpicture

                  enddocument





                  share|improve this answer
























                    up vote
                    6
                    down vote













                    As I mention in a comment, a ycomb plot can be used for this. Here are two examples, the first a modified version of marmot's code, the second a more verbose (and probably more complicated than it needs to be) version using pgfplots.



                    enter image description here



                    documentclass[border=5mm]standalone
                    usepackagepgfplots
                    pgfplotssetcompat=1.3
                    begindocument
                    begintikzpicture[
                    declare function=
                    M(x) = 4-(x-4)*(x-4)/4;

                    ]
                    draw[latex-latex] (0,6) node[left] $mathbfM$ |- (8.5,0) node[below]
                    $mathbfL$;
                    draw[thick] plot[variable=x,domain=0:8,smooth] (x,M(x));
                    draw[thick] plot[variable=x,domain=0:8,ycomb] (x,M(x));
                    endtikzpicture

                    begintikzpicture
                    beginaxis[
                    declare function=
                    t = 2;
                    mid = 5;
                    d=4.5;
                    M(x) = -(x-mid)^2*(t/d^2) + t;
                    ,
                    axis lines=middle,
                    xtick=empty, ytick=empty,
                    ylabel=$M$, xlabel=$L$,
                    enlarge x limits,
                    enlarge y limits=value=0.5,upper,
                    domain=mid-d:mid+d
                    ]

                    addplot [thick] M(x) node[midway, above] $M_max = frac18 qL$;
                    addplot [ycomb, samples=15] M(x);
                    endaxis
                    endtikzpicture

                    enddocument





                    share|improve this answer






















                      up vote
                      6
                      down vote










                      up vote
                      6
                      down vote









                      As I mention in a comment, a ycomb plot can be used for this. Here are two examples, the first a modified version of marmot's code, the second a more verbose (and probably more complicated than it needs to be) version using pgfplots.



                      enter image description here



                      documentclass[border=5mm]standalone
                      usepackagepgfplots
                      pgfplotssetcompat=1.3
                      begindocument
                      begintikzpicture[
                      declare function=
                      M(x) = 4-(x-4)*(x-4)/4;

                      ]
                      draw[latex-latex] (0,6) node[left] $mathbfM$ |- (8.5,0) node[below]
                      $mathbfL$;
                      draw[thick] plot[variable=x,domain=0:8,smooth] (x,M(x));
                      draw[thick] plot[variable=x,domain=0:8,ycomb] (x,M(x));
                      endtikzpicture

                      begintikzpicture
                      beginaxis[
                      declare function=
                      t = 2;
                      mid = 5;
                      d=4.5;
                      M(x) = -(x-mid)^2*(t/d^2) + t;
                      ,
                      axis lines=middle,
                      xtick=empty, ytick=empty,
                      ylabel=$M$, xlabel=$L$,
                      enlarge x limits,
                      enlarge y limits=value=0.5,upper,
                      domain=mid-d:mid+d
                      ]

                      addplot [thick] M(x) node[midway, above] $M_max = frac18 qL$;
                      addplot [ycomb, samples=15] M(x);
                      endaxis
                      endtikzpicture

                      enddocument





                      share|improve this answer












                      As I mention in a comment, a ycomb plot can be used for this. Here are two examples, the first a modified version of marmot's code, the second a more verbose (and probably more complicated than it needs to be) version using pgfplots.



                      enter image description here



                      documentclass[border=5mm]standalone
                      usepackagepgfplots
                      pgfplotssetcompat=1.3
                      begindocument
                      begintikzpicture[
                      declare function=
                      M(x) = 4-(x-4)*(x-4)/4;

                      ]
                      draw[latex-latex] (0,6) node[left] $mathbfM$ |- (8.5,0) node[below]
                      $mathbfL$;
                      draw[thick] plot[variable=x,domain=0:8,smooth] (x,M(x));
                      draw[thick] plot[variable=x,domain=0:8,ycomb] (x,M(x));
                      endtikzpicture

                      begintikzpicture
                      beginaxis[
                      declare function=
                      t = 2;
                      mid = 5;
                      d=4.5;
                      M(x) = -(x-mid)^2*(t/d^2) + t;
                      ,
                      axis lines=middle,
                      xtick=empty, ytick=empty,
                      ylabel=$M$, xlabel=$L$,
                      enlarge x limits,
                      enlarge y limits=value=0.5,upper,
                      domain=mid-d:mid+d
                      ]

                      addplot [thick] M(x) node[midway, above] $M_max = frac18 qL$;
                      addplot [ycomb, samples=15] M(x);
                      endaxis
                      endtikzpicture

                      enddocument






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Nov 10 at 16:38









                      Torbjørn T.

                      153k13245433




                      153k13245433




















                          up vote
                          5
                          down vote













                          Here is one more possibility: use a pattern. And if you use clip, as suggested by @nidhin, I'd use a grid rather than a foreach loop. In fact, if you use foreach, since the function is known, you do not need clip.



                          documentclass[tikz,border=3.14mm]standalone
                          usetikzlibrarypatterns
                          usepackageamsmath
                          begindocument
                          begintikzpicture
                          draw[latex-latex] (0,6) node[left] $boldsymbolM$ |- (8.5,0) node[below]
                          $boldsymbolL$;
                          draw[thick,pattern=vertical lines] plot[variable=x,domain=0:8,smooth] (x,4-(x-4)*(x-4)/4);
                          endtikzpicture

                          begintikzpicture
                          draw[latex-latex] (0,6) node[left] $boldsymbolM$ |- (8.5,0) node[below]
                          $boldsymbolL$;
                          draw[thick] plot[variable=x,domain=0:8,smooth] (x,4-(x-4)*(x-4)/4);
                          clip plot[variable=x,domain=0:8,smooth] (x,4-(x-4)*(x-4)/4);
                          draw (0,0) grid[xstep=1cm,ystep=6cm] (8,5);
                          endtikzpicture
                          enddocument


                          enter image description here






                          share|improve this answer
























                            up vote
                            5
                            down vote













                            Here is one more possibility: use a pattern. And if you use clip, as suggested by @nidhin, I'd use a grid rather than a foreach loop. In fact, if you use foreach, since the function is known, you do not need clip.



                            documentclass[tikz,border=3.14mm]standalone
                            usetikzlibrarypatterns
                            usepackageamsmath
                            begindocument
                            begintikzpicture
                            draw[latex-latex] (0,6) node[left] $boldsymbolM$ |- (8.5,0) node[below]
                            $boldsymbolL$;
                            draw[thick,pattern=vertical lines] plot[variable=x,domain=0:8,smooth] (x,4-(x-4)*(x-4)/4);
                            endtikzpicture

                            begintikzpicture
                            draw[latex-latex] (0,6) node[left] $boldsymbolM$ |- (8.5,0) node[below]
                            $boldsymbolL$;
                            draw[thick] plot[variable=x,domain=0:8,smooth] (x,4-(x-4)*(x-4)/4);
                            clip plot[variable=x,domain=0:8,smooth] (x,4-(x-4)*(x-4)/4);
                            draw (0,0) grid[xstep=1cm,ystep=6cm] (8,5);
                            endtikzpicture
                            enddocument


                            enter image description here






                            share|improve this answer






















                              up vote
                              5
                              down vote










                              up vote
                              5
                              down vote









                              Here is one more possibility: use a pattern. And if you use clip, as suggested by @nidhin, I'd use a grid rather than a foreach loop. In fact, if you use foreach, since the function is known, you do not need clip.



                              documentclass[tikz,border=3.14mm]standalone
                              usetikzlibrarypatterns
                              usepackageamsmath
                              begindocument
                              begintikzpicture
                              draw[latex-latex] (0,6) node[left] $boldsymbolM$ |- (8.5,0) node[below]
                              $boldsymbolL$;
                              draw[thick,pattern=vertical lines] plot[variable=x,domain=0:8,smooth] (x,4-(x-4)*(x-4)/4);
                              endtikzpicture

                              begintikzpicture
                              draw[latex-latex] (0,6) node[left] $boldsymbolM$ |- (8.5,0) node[below]
                              $boldsymbolL$;
                              draw[thick] plot[variable=x,domain=0:8,smooth] (x,4-(x-4)*(x-4)/4);
                              clip plot[variable=x,domain=0:8,smooth] (x,4-(x-4)*(x-4)/4);
                              draw (0,0) grid[xstep=1cm,ystep=6cm] (8,5);
                              endtikzpicture
                              enddocument


                              enter image description here






                              share|improve this answer












                              Here is one more possibility: use a pattern. And if you use clip, as suggested by @nidhin, I'd use a grid rather than a foreach loop. In fact, if you use foreach, since the function is known, you do not need clip.



                              documentclass[tikz,border=3.14mm]standalone
                              usetikzlibrarypatterns
                              usepackageamsmath
                              begindocument
                              begintikzpicture
                              draw[latex-latex] (0,6) node[left] $boldsymbolM$ |- (8.5,0) node[below]
                              $boldsymbolL$;
                              draw[thick,pattern=vertical lines] plot[variable=x,domain=0:8,smooth] (x,4-(x-4)*(x-4)/4);
                              endtikzpicture

                              begintikzpicture
                              draw[latex-latex] (0,6) node[left] $boldsymbolM$ |- (8.5,0) node[below]
                              $boldsymbolL$;
                              draw[thick] plot[variable=x,domain=0:8,smooth] (x,4-(x-4)*(x-4)/4);
                              clip plot[variable=x,domain=0:8,smooth] (x,4-(x-4)*(x-4)/4);
                              draw (0,0) grid[xstep=1cm,ystep=6cm] (8,5);
                              endtikzpicture
                              enddocument


                              enter image description here







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Nov 10 at 16:02









                              marmot

                              76.6k487161




                              76.6k487161




















                                  up vote
                                  4
                                  down vote













                                  Using clip



                                  documentclassstandalone
                                  usepackageamsmath
                                  usepackagetikz
                                  begindocument
                                  begintikzpicture[>=latex]
                                  draw(4,5) node $M_max = dfrac18 cdot q cdot L^2$;
                                  draw[<->] (0,6) node[above]M--(0,0)--(9,0)node[right]L;
                                  draw[clip] (0,0) .. controls (3,6) and (5,6) .. (8,0) --cycle;
                                  foreach i in 0,0.5,...,8
                                  draw (i,0) -- ++ (0,10);
                                  endtikzpicture
                                  enddocument


                                  enter image description here






                                  share|improve this answer
























                                    up vote
                                    4
                                    down vote













                                    Using clip



                                    documentclassstandalone
                                    usepackageamsmath
                                    usepackagetikz
                                    begindocument
                                    begintikzpicture[>=latex]
                                    draw(4,5) node $M_max = dfrac18 cdot q cdot L^2$;
                                    draw[<->] (0,6) node[above]M--(0,0)--(9,0)node[right]L;
                                    draw[clip] (0,0) .. controls (3,6) and (5,6) .. (8,0) --cycle;
                                    foreach i in 0,0.5,...,8
                                    draw (i,0) -- ++ (0,10);
                                    endtikzpicture
                                    enddocument


                                    enter image description here






                                    share|improve this answer






















                                      up vote
                                      4
                                      down vote










                                      up vote
                                      4
                                      down vote









                                      Using clip



                                      documentclassstandalone
                                      usepackageamsmath
                                      usepackagetikz
                                      begindocument
                                      begintikzpicture[>=latex]
                                      draw(4,5) node $M_max = dfrac18 cdot q cdot L^2$;
                                      draw[<->] (0,6) node[above]M--(0,0)--(9,0)node[right]L;
                                      draw[clip] (0,0) .. controls (3,6) and (5,6) .. (8,0) --cycle;
                                      foreach i in 0,0.5,...,8
                                      draw (i,0) -- ++ (0,10);
                                      endtikzpicture
                                      enddocument


                                      enter image description here






                                      share|improve this answer












                                      Using clip



                                      documentclassstandalone
                                      usepackageamsmath
                                      usepackagetikz
                                      begindocument
                                      begintikzpicture[>=latex]
                                      draw(4,5) node $M_max = dfrac18 cdot q cdot L^2$;
                                      draw[<->] (0,6) node[above]M--(0,0)--(9,0)node[right]L;
                                      draw[clip] (0,0) .. controls (3,6) and (5,6) .. (8,0) --cycle;
                                      foreach i in 0,0.5,...,8
                                      draw (i,0) -- ++ (0,10);
                                      endtikzpicture
                                      enddocument


                                      enter image description here







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Nov 10 at 15:46









                                      nidhin

                                      1,450820




                                      1,450820



























                                           

                                          draft saved


                                          draft discarded















































                                           


                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function ()
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f459323%2fhow-can-i-make-a-curved-graph-in-tikz-and-vertical-lines-from-the-x-axis-to-that%23new-answer', 'question_page');

                                          );

                                          Post as a guest















                                          Required, but never shown





















































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown

































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown







                                          Popular posts from this blog

                                          Top Tejano songwriter Luis Silva dead of heart attack at 64

                                          ReactJS Fetched API data displays live - need Data displayed static

                                          政党