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

53136




53136










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:



documentclass{article}
usepackage{amsmath}
usepackage{tikz}
usetikzlibrary{calc,intersections}

begin{document}
begin{tikzpicture}
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} = dfrac{1}{8} 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);
}
end{tikzpicture}
end{document}


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} = dfrac{1}{8} 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}
    usepackage{pgfplots}
    pgfplotsset{compat=1.3}
    begin{document}
    begin{tikzpicture}[
    declare function={
    M(x) = 4-(x-4)*(x-4)/4;
    }
    ]
    draw[latex-latex] (0,6) node[left] {$mathbf{M}$} |- (8.5,0) node[below]
    {$mathbf{L}$};
    draw[thick] plot[variable=x,domain=0:8,smooth] ({x},{M(x)});
    draw[thick] plot[variable=x,domain=0:8,ycomb] ({x},{M(x)});
    end{tikzpicture}

    begin{tikzpicture}
    begin{axis}[
    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} = frac{1}{8} qL$};
    addplot [ycomb, samples=15] {M(x)};
    end{axis}
    end{tikzpicture}

    end{document}





    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}
      usetikzlibrary{patterns}
      usepackage{amsmath}
      begin{document}
      begin{tikzpicture}
      draw[latex-latex] (0,6) node[left] {$boldsymbol{M}$} |- (8.5,0) node[below]
      {$boldsymbol{L}$};
      draw[thick,pattern=vertical lines] plot[variable=x,domain=0:8,smooth] ({x},{4-(x-4)*(x-4)/4});
      end{tikzpicture}

      begin{tikzpicture}
      draw[latex-latex] (0,6) node[left] {$boldsymbol{M}$} |- (8.5,0) node[below]
      {$boldsymbol{L}$};
      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);
      end{tikzpicture}
      end{document}


      enter image description here






      share|improve this answer




























        up vote
        4
        down vote













        Using clip



        documentclass{standalone}
        usepackage{amsmath}
        usepackage{tikz}
        begin{document}
        begin{tikzpicture}[>=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);
        end{tikzpicture}
        end{document}


        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:



          documentclass{article}
          usepackage{amsmath}
          usepackage{tikz}
          usetikzlibrary{calc,intersections}

          begin{document}
          begin{tikzpicture}
          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} = dfrac{1}{8} 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);
          }
          end{tikzpicture}
          end{document}


          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} = dfrac{1}{8} 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:



            documentclass{article}
            usepackage{amsmath}
            usepackage{tikz}
            usetikzlibrary{calc,intersections}

            begin{document}
            begin{tikzpicture}
            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} = dfrac{1}{8} 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);
            }
            end{tikzpicture}
            end{document}


            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} = dfrac{1}{8} 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:



              documentclass{article}
              usepackage{amsmath}
              usepackage{tikz}
              usetikzlibrary{calc,intersections}

              begin{document}
              begin{tikzpicture}
              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} = dfrac{1}{8} 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);
              }
              end{tikzpicture}
              end{document}


              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} = dfrac{1}{8} 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:



              documentclass{article}
              usepackage{amsmath}
              usepackage{tikz}
              usetikzlibrary{calc,intersections}

              begin{document}
              begin{tikzpicture}
              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} = dfrac{1}{8} 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);
              }
              end{tikzpicture}
              end{document}


              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} = dfrac{1}{8} 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}
                  usepackage{pgfplots}
                  pgfplotsset{compat=1.3}
                  begin{document}
                  begin{tikzpicture}[
                  declare function={
                  M(x) = 4-(x-4)*(x-4)/4;
                  }
                  ]
                  draw[latex-latex] (0,6) node[left] {$mathbf{M}$} |- (8.5,0) node[below]
                  {$mathbf{L}$};
                  draw[thick] plot[variable=x,domain=0:8,smooth] ({x},{M(x)});
                  draw[thick] plot[variable=x,domain=0:8,ycomb] ({x},{M(x)});
                  end{tikzpicture}

                  begin{tikzpicture}
                  begin{axis}[
                  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} = frac{1}{8} qL$};
                  addplot [ycomb, samples=15] {M(x)};
                  end{axis}
                  end{tikzpicture}

                  end{document}





                  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}
                    usepackage{pgfplots}
                    pgfplotsset{compat=1.3}
                    begin{document}
                    begin{tikzpicture}[
                    declare function={
                    M(x) = 4-(x-4)*(x-4)/4;
                    }
                    ]
                    draw[latex-latex] (0,6) node[left] {$mathbf{M}$} |- (8.5,0) node[below]
                    {$mathbf{L}$};
                    draw[thick] plot[variable=x,domain=0:8,smooth] ({x},{M(x)});
                    draw[thick] plot[variable=x,domain=0:8,ycomb] ({x},{M(x)});
                    end{tikzpicture}

                    begin{tikzpicture}
                    begin{axis}[
                    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} = frac{1}{8} qL$};
                    addplot [ycomb, samples=15] {M(x)};
                    end{axis}
                    end{tikzpicture}

                    end{document}





                    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}
                      usepackage{pgfplots}
                      pgfplotsset{compat=1.3}
                      begin{document}
                      begin{tikzpicture}[
                      declare function={
                      M(x) = 4-(x-4)*(x-4)/4;
                      }
                      ]
                      draw[latex-latex] (0,6) node[left] {$mathbf{M}$} |- (8.5,0) node[below]
                      {$mathbf{L}$};
                      draw[thick] plot[variable=x,domain=0:8,smooth] ({x},{M(x)});
                      draw[thick] plot[variable=x,domain=0:8,ycomb] ({x},{M(x)});
                      end{tikzpicture}

                      begin{tikzpicture}
                      begin{axis}[
                      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} = frac{1}{8} qL$};
                      addplot [ycomb, samples=15] {M(x)};
                      end{axis}
                      end{tikzpicture}

                      end{document}





                      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}
                      usepackage{pgfplots}
                      pgfplotsset{compat=1.3}
                      begin{document}
                      begin{tikzpicture}[
                      declare function={
                      M(x) = 4-(x-4)*(x-4)/4;
                      }
                      ]
                      draw[latex-latex] (0,6) node[left] {$mathbf{M}$} |- (8.5,0) node[below]
                      {$mathbf{L}$};
                      draw[thick] plot[variable=x,domain=0:8,smooth] ({x},{M(x)});
                      draw[thick] plot[variable=x,domain=0:8,ycomb] ({x},{M(x)});
                      end{tikzpicture}

                      begin{tikzpicture}
                      begin{axis}[
                      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} = frac{1}{8} qL$};
                      addplot [ycomb, samples=15] {M(x)};
                      end{axis}
                      end{tikzpicture}

                      end{document}






                      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}
                          usetikzlibrary{patterns}
                          usepackage{amsmath}
                          begin{document}
                          begin{tikzpicture}
                          draw[latex-latex] (0,6) node[left] {$boldsymbol{M}$} |- (8.5,0) node[below]
                          {$boldsymbol{L}$};
                          draw[thick,pattern=vertical lines] plot[variable=x,domain=0:8,smooth] ({x},{4-(x-4)*(x-4)/4});
                          end{tikzpicture}

                          begin{tikzpicture}
                          draw[latex-latex] (0,6) node[left] {$boldsymbol{M}$} |- (8.5,0) node[below]
                          {$boldsymbol{L}$};
                          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);
                          end{tikzpicture}
                          end{document}


                          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}
                            usetikzlibrary{patterns}
                            usepackage{amsmath}
                            begin{document}
                            begin{tikzpicture}
                            draw[latex-latex] (0,6) node[left] {$boldsymbol{M}$} |- (8.5,0) node[below]
                            {$boldsymbol{L}$};
                            draw[thick,pattern=vertical lines] plot[variable=x,domain=0:8,smooth] ({x},{4-(x-4)*(x-4)/4});
                            end{tikzpicture}

                            begin{tikzpicture}
                            draw[latex-latex] (0,6) node[left] {$boldsymbol{M}$} |- (8.5,0) node[below]
                            {$boldsymbol{L}$};
                            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);
                            end{tikzpicture}
                            end{document}


                            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}
                              usetikzlibrary{patterns}
                              usepackage{amsmath}
                              begin{document}
                              begin{tikzpicture}
                              draw[latex-latex] (0,6) node[left] {$boldsymbol{M}$} |- (8.5,0) node[below]
                              {$boldsymbol{L}$};
                              draw[thick,pattern=vertical lines] plot[variable=x,domain=0:8,smooth] ({x},{4-(x-4)*(x-4)/4});
                              end{tikzpicture}

                              begin{tikzpicture}
                              draw[latex-latex] (0,6) node[left] {$boldsymbol{M}$} |- (8.5,0) node[below]
                              {$boldsymbol{L}$};
                              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);
                              end{tikzpicture}
                              end{document}


                              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}
                              usetikzlibrary{patterns}
                              usepackage{amsmath}
                              begin{document}
                              begin{tikzpicture}
                              draw[latex-latex] (0,6) node[left] {$boldsymbol{M}$} |- (8.5,0) node[below]
                              {$boldsymbol{L}$};
                              draw[thick,pattern=vertical lines] plot[variable=x,domain=0:8,smooth] ({x},{4-(x-4)*(x-4)/4});
                              end{tikzpicture}

                              begin{tikzpicture}
                              draw[latex-latex] (0,6) node[left] {$boldsymbol{M}$} |- (8.5,0) node[below]
                              {$boldsymbol{L}$};
                              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);
                              end{tikzpicture}
                              end{document}


                              enter image description here







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Nov 10 at 16:02









                              marmot

                              79.5k490168




                              79.5k490168






















                                  up vote
                                  4
                                  down vote













                                  Using clip



                                  documentclass{standalone}
                                  usepackage{amsmath}
                                  usepackage{tikz}
                                  begin{document}
                                  begin{tikzpicture}[>=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);
                                  end{tikzpicture}
                                  end{document}


                                  enter image description here






                                  share|improve this answer

























                                    up vote
                                    4
                                    down vote













                                    Using clip



                                    documentclass{standalone}
                                    usepackage{amsmath}
                                    usepackage{tikz}
                                    begin{document}
                                    begin{tikzpicture}[>=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);
                                    end{tikzpicture}
                                    end{document}


                                    enter image description here






                                    share|improve this answer























                                      up vote
                                      4
                                      down vote










                                      up vote
                                      4
                                      down vote









                                      Using clip



                                      documentclass{standalone}
                                      usepackage{amsmath}
                                      usepackage{tikz}
                                      begin{document}
                                      begin{tikzpicture}[>=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);
                                      end{tikzpicture}
                                      end{document}


                                      enter image description here






                                      share|improve this answer












                                      Using clip



                                      documentclass{standalone}
                                      usepackage{amsmath}
                                      usepackage{tikz}
                                      begin{document}
                                      begin{tikzpicture}[>=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);
                                      end{tikzpicture}
                                      end{document}


                                      enter image description here







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Nov 10 at 15:46









                                      nidhin

                                      1,927922




                                      1,927922






























                                          draft saved

                                          draft discarded




















































                                          Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid



                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.


                                          To learn more, see our tips on writing great answers.





                                          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                          Please pay close attention to the following guidance:


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid



                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.


                                          To learn more, see our tips on writing great answers.




                                          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

                                          鏡平學校

                                          ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

                                          Why https connections are so slow when debugging (stepping over) in Java?