Filling in Area Under Curve Causes Alignment Issues












6















I am trying to fill in the area under the curve of sin(x)/x. Here is my code:



PassOptionsToPackage{usenames,dvipsnames,table,x11names}{xcolor}
documentclass[a4paper, 12pt]{article}

usepackage{amsmath}
usepackage{amssymb}
usepackage{pgfplots}
usepackage{tkz-euclide}
pgfplotsset{compat=1.15}
usetikzlibrary{arrows,shadows,positioning, calc, decorations.markings, hobby, quotes,angles,decorations.pathreplacing,intersections}
usepgfplotslibrary{polar,colormaps,fillbetween}
usepgflibrary{shapes.geometric}
usepackage{xcolor}

begin{document}

begin{figure}[ht]

centering

begin{tikzpicture}[scale=1.5,line width=1pt]
begin{axis}[
color= black,
xmin=-1,
xmax=7.9,
ymin=-1,
ymax=2,
axis equal image,
axis lines=middle,
font=scriptsize,
xtick distance=1,
ytick distance=1,
%xticklabels={},
%yticklabels={},
inner axis line style={stealth-stealth},
xlabel = {$x$},
ylabel = {$f(x)$},
ticks=none,
]

addplot[black, opacity = 0, domain=0:10, name path = 1]{0};

addplot[Tan, smooth, domain=0.01:7.5, samples = 300, name path=2, thick] {sin(deg(x))/x};

%addplot[Tan, fill opacity=0.25] fill between [of=1 and 2,soft clip={domain=0:3.1415}];

end{axis}
end{tikzpicture}

caption{Integrating $sin(x)/x$ from $0 le x < infty$.}
label{1}

end{figure}

end{document}


I have the code in a larger document, so here is the output:



enter image description here



When I un-comment out the line to fill in the area, this happens:



enter image description here



There is a noticeable vertical gap and the image is pushed to the left. Any idea why this is happening?










share|improve this question



























    6















    I am trying to fill in the area under the curve of sin(x)/x. Here is my code:



    PassOptionsToPackage{usenames,dvipsnames,table,x11names}{xcolor}
    documentclass[a4paper, 12pt]{article}

    usepackage{amsmath}
    usepackage{amssymb}
    usepackage{pgfplots}
    usepackage{tkz-euclide}
    pgfplotsset{compat=1.15}
    usetikzlibrary{arrows,shadows,positioning, calc, decorations.markings, hobby, quotes,angles,decorations.pathreplacing,intersections}
    usepgfplotslibrary{polar,colormaps,fillbetween}
    usepgflibrary{shapes.geometric}
    usepackage{xcolor}

    begin{document}

    begin{figure}[ht]

    centering

    begin{tikzpicture}[scale=1.5,line width=1pt]
    begin{axis}[
    color= black,
    xmin=-1,
    xmax=7.9,
    ymin=-1,
    ymax=2,
    axis equal image,
    axis lines=middle,
    font=scriptsize,
    xtick distance=1,
    ytick distance=1,
    %xticklabels={},
    %yticklabels={},
    inner axis line style={stealth-stealth},
    xlabel = {$x$},
    ylabel = {$f(x)$},
    ticks=none,
    ]

    addplot[black, opacity = 0, domain=0:10, name path = 1]{0};

    addplot[Tan, smooth, domain=0.01:7.5, samples = 300, name path=2, thick] {sin(deg(x))/x};

    %addplot[Tan, fill opacity=0.25] fill between [of=1 and 2,soft clip={domain=0:3.1415}];

    end{axis}
    end{tikzpicture}

    caption{Integrating $sin(x)/x$ from $0 le x < infty$.}
    label{1}

    end{figure}

    end{document}


    I have the code in a larger document, so here is the output:



    enter image description here



    When I un-comment out the line to fill in the area, this happens:



    enter image description here



    There is a noticeable vertical gap and the image is pushed to the left. Any idea why this is happening?










    share|improve this question

























      6












      6








      6


      0






      I am trying to fill in the area under the curve of sin(x)/x. Here is my code:



      PassOptionsToPackage{usenames,dvipsnames,table,x11names}{xcolor}
      documentclass[a4paper, 12pt]{article}

      usepackage{amsmath}
      usepackage{amssymb}
      usepackage{pgfplots}
      usepackage{tkz-euclide}
      pgfplotsset{compat=1.15}
      usetikzlibrary{arrows,shadows,positioning, calc, decorations.markings, hobby, quotes,angles,decorations.pathreplacing,intersections}
      usepgfplotslibrary{polar,colormaps,fillbetween}
      usepgflibrary{shapes.geometric}
      usepackage{xcolor}

      begin{document}

      begin{figure}[ht]

      centering

      begin{tikzpicture}[scale=1.5,line width=1pt]
      begin{axis}[
      color= black,
      xmin=-1,
      xmax=7.9,
      ymin=-1,
      ymax=2,
      axis equal image,
      axis lines=middle,
      font=scriptsize,
      xtick distance=1,
      ytick distance=1,
      %xticklabels={},
      %yticklabels={},
      inner axis line style={stealth-stealth},
      xlabel = {$x$},
      ylabel = {$f(x)$},
      ticks=none,
      ]

      addplot[black, opacity = 0, domain=0:10, name path = 1]{0};

      addplot[Tan, smooth, domain=0.01:7.5, samples = 300, name path=2, thick] {sin(deg(x))/x};

      %addplot[Tan, fill opacity=0.25] fill between [of=1 and 2,soft clip={domain=0:3.1415}];

      end{axis}
      end{tikzpicture}

      caption{Integrating $sin(x)/x$ from $0 le x < infty$.}
      label{1}

      end{figure}

      end{document}


      I have the code in a larger document, so here is the output:



      enter image description here



      When I un-comment out the line to fill in the area, this happens:



      enter image description here



      There is a noticeable vertical gap and the image is pushed to the left. Any idea why this is happening?










      share|improve this question














      I am trying to fill in the area under the curve of sin(x)/x. Here is my code:



      PassOptionsToPackage{usenames,dvipsnames,table,x11names}{xcolor}
      documentclass[a4paper, 12pt]{article}

      usepackage{amsmath}
      usepackage{amssymb}
      usepackage{pgfplots}
      usepackage{tkz-euclide}
      pgfplotsset{compat=1.15}
      usetikzlibrary{arrows,shadows,positioning, calc, decorations.markings, hobby, quotes,angles,decorations.pathreplacing,intersections}
      usepgfplotslibrary{polar,colormaps,fillbetween}
      usepgflibrary{shapes.geometric}
      usepackage{xcolor}

      begin{document}

      begin{figure}[ht]

      centering

      begin{tikzpicture}[scale=1.5,line width=1pt]
      begin{axis}[
      color= black,
      xmin=-1,
      xmax=7.9,
      ymin=-1,
      ymax=2,
      axis equal image,
      axis lines=middle,
      font=scriptsize,
      xtick distance=1,
      ytick distance=1,
      %xticklabels={},
      %yticklabels={},
      inner axis line style={stealth-stealth},
      xlabel = {$x$},
      ylabel = {$f(x)$},
      ticks=none,
      ]

      addplot[black, opacity = 0, domain=0:10, name path = 1]{0};

      addplot[Tan, smooth, domain=0.01:7.5, samples = 300, name path=2, thick] {sin(deg(x))/x};

      %addplot[Tan, fill opacity=0.25] fill between [of=1 and 2,soft clip={domain=0:3.1415}];

      end{axis}
      end{tikzpicture}

      caption{Integrating $sin(x)/x$ from $0 le x < infty$.}
      label{1}

      end{figure}

      end{document}


      I have the code in a larger document, so here is the output:



      enter image description here



      When I un-comment out the line to fill in the area, this happens:



      enter image description here



      There is a noticeable vertical gap and the image is pushed to the left. Any idea why this is happening?







      pgfplots fillbetween






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 10 hours ago









      Aiden KennyAiden Kenny

      4437




      4437






















          1 Answer
          1






          active

          oldest

          votes


















          9














          The culprit is scale=1.5, which you should pass to the axis, and not to the tikzpicture. I guess you confuse pgfplots otherwise, see this answer. If you wish to have a core-level explanation, I am afraid I cannot provide it, but given this answer one of my first guesses was to change the position of scale, and it seems to work. Notice also that the pgfplots library fillbetween loads intersections, but a slightly advanced version, so you should not load intersections (again). I also removed tkz-euclide and unused libraries (in order to keep the code tidy), but you may resurrect them and the code still works as it should.



          PassOptionsToPackage{usenames,dvipsnames,table,x11names}{xcolor}
          documentclass[a4paper, 12pt]{article}
          usepackage{amsmath}
          usepackage{amssymb}
          usepackage{pgfplots}
          %usepackage{tkz-euclide}
          pgfplotsset{compat=1.15}
          usepgfplotslibrary{%polar,colormaps,
          fillbetween}
          % usetikzlibrary{arrows,shadows,positioning, calc, decorations.markings, hobby, quotes,angles,decorations.pathreplacing}
          % usepgflibrary{shapes.geometric}
          %usepackage{xcolor}


          begin{document}

          begin{figure}[ht]

          centering

          begin{tikzpicture}[line width=1pt]
          begin{axis}[scale=1.5,
          color= black,
          xmin=-1,
          xmax=7.9,
          ymin=-1,
          ymax=2,
          axis equal image,
          axis lines=middle,
          font=scriptsize,
          xtick distance=1,
          ytick distance=1,
          %xticklabels={},
          %yticklabels={},
          inner axis line style={stealth-stealth},
          xlabel = {$x$},
          ylabel = {$f(x)$},
          ticks=none,
          ]
          addplot[black, opacity = 0, domain=0:10, name path = 1]{0};

          addplot[Tan, smooth, domain=0.01:7.5, samples = 300, name path=2, thick] {sin(deg(x))/x};

          addplot[Tan, fill opacity=0.25] fill between [of=1 and 2,soft clip={domain=0:3.1415}];

          end{axis}
          end{tikzpicture}
          caption{Integrating $sin(x)/x$ from $0 le x < infty$.}
          label{1}
          end{figure}
          end{document}


          enter image description here






          share|improve this answer





















          • 2





            Perfect, thanks. I'm always curious about small issues like this because the solution is not at all obvious.

            – Aiden Kenny
            8 hours 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',
          autoActivateHeartbeat: false,
          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%2f477872%2ffilling-in-area-under-curve-causes-alignment-issues%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          9














          The culprit is scale=1.5, which you should pass to the axis, and not to the tikzpicture. I guess you confuse pgfplots otherwise, see this answer. If you wish to have a core-level explanation, I am afraid I cannot provide it, but given this answer one of my first guesses was to change the position of scale, and it seems to work. Notice also that the pgfplots library fillbetween loads intersections, but a slightly advanced version, so you should not load intersections (again). I also removed tkz-euclide and unused libraries (in order to keep the code tidy), but you may resurrect them and the code still works as it should.



          PassOptionsToPackage{usenames,dvipsnames,table,x11names}{xcolor}
          documentclass[a4paper, 12pt]{article}
          usepackage{amsmath}
          usepackage{amssymb}
          usepackage{pgfplots}
          %usepackage{tkz-euclide}
          pgfplotsset{compat=1.15}
          usepgfplotslibrary{%polar,colormaps,
          fillbetween}
          % usetikzlibrary{arrows,shadows,positioning, calc, decorations.markings, hobby, quotes,angles,decorations.pathreplacing}
          % usepgflibrary{shapes.geometric}
          %usepackage{xcolor}


          begin{document}

          begin{figure}[ht]

          centering

          begin{tikzpicture}[line width=1pt]
          begin{axis}[scale=1.5,
          color= black,
          xmin=-1,
          xmax=7.9,
          ymin=-1,
          ymax=2,
          axis equal image,
          axis lines=middle,
          font=scriptsize,
          xtick distance=1,
          ytick distance=1,
          %xticklabels={},
          %yticklabels={},
          inner axis line style={stealth-stealth},
          xlabel = {$x$},
          ylabel = {$f(x)$},
          ticks=none,
          ]
          addplot[black, opacity = 0, domain=0:10, name path = 1]{0};

          addplot[Tan, smooth, domain=0.01:7.5, samples = 300, name path=2, thick] {sin(deg(x))/x};

          addplot[Tan, fill opacity=0.25] fill between [of=1 and 2,soft clip={domain=0:3.1415}];

          end{axis}
          end{tikzpicture}
          caption{Integrating $sin(x)/x$ from $0 le x < infty$.}
          label{1}
          end{figure}
          end{document}


          enter image description here






          share|improve this answer





















          • 2





            Perfect, thanks. I'm always curious about small issues like this because the solution is not at all obvious.

            – Aiden Kenny
            8 hours ago
















          9














          The culprit is scale=1.5, which you should pass to the axis, and not to the tikzpicture. I guess you confuse pgfplots otherwise, see this answer. If you wish to have a core-level explanation, I am afraid I cannot provide it, but given this answer one of my first guesses was to change the position of scale, and it seems to work. Notice also that the pgfplots library fillbetween loads intersections, but a slightly advanced version, so you should not load intersections (again). I also removed tkz-euclide and unused libraries (in order to keep the code tidy), but you may resurrect them and the code still works as it should.



          PassOptionsToPackage{usenames,dvipsnames,table,x11names}{xcolor}
          documentclass[a4paper, 12pt]{article}
          usepackage{amsmath}
          usepackage{amssymb}
          usepackage{pgfplots}
          %usepackage{tkz-euclide}
          pgfplotsset{compat=1.15}
          usepgfplotslibrary{%polar,colormaps,
          fillbetween}
          % usetikzlibrary{arrows,shadows,positioning, calc, decorations.markings, hobby, quotes,angles,decorations.pathreplacing}
          % usepgflibrary{shapes.geometric}
          %usepackage{xcolor}


          begin{document}

          begin{figure}[ht]

          centering

          begin{tikzpicture}[line width=1pt]
          begin{axis}[scale=1.5,
          color= black,
          xmin=-1,
          xmax=7.9,
          ymin=-1,
          ymax=2,
          axis equal image,
          axis lines=middle,
          font=scriptsize,
          xtick distance=1,
          ytick distance=1,
          %xticklabels={},
          %yticklabels={},
          inner axis line style={stealth-stealth},
          xlabel = {$x$},
          ylabel = {$f(x)$},
          ticks=none,
          ]
          addplot[black, opacity = 0, domain=0:10, name path = 1]{0};

          addplot[Tan, smooth, domain=0.01:7.5, samples = 300, name path=2, thick] {sin(deg(x))/x};

          addplot[Tan, fill opacity=0.25] fill between [of=1 and 2,soft clip={domain=0:3.1415}];

          end{axis}
          end{tikzpicture}
          caption{Integrating $sin(x)/x$ from $0 le x < infty$.}
          label{1}
          end{figure}
          end{document}


          enter image description here






          share|improve this answer





















          • 2





            Perfect, thanks. I'm always curious about small issues like this because the solution is not at all obvious.

            – Aiden Kenny
            8 hours ago














          9












          9








          9







          The culprit is scale=1.5, which you should pass to the axis, and not to the tikzpicture. I guess you confuse pgfplots otherwise, see this answer. If you wish to have a core-level explanation, I am afraid I cannot provide it, but given this answer one of my first guesses was to change the position of scale, and it seems to work. Notice also that the pgfplots library fillbetween loads intersections, but a slightly advanced version, so you should not load intersections (again). I also removed tkz-euclide and unused libraries (in order to keep the code tidy), but you may resurrect them and the code still works as it should.



          PassOptionsToPackage{usenames,dvipsnames,table,x11names}{xcolor}
          documentclass[a4paper, 12pt]{article}
          usepackage{amsmath}
          usepackage{amssymb}
          usepackage{pgfplots}
          %usepackage{tkz-euclide}
          pgfplotsset{compat=1.15}
          usepgfplotslibrary{%polar,colormaps,
          fillbetween}
          % usetikzlibrary{arrows,shadows,positioning, calc, decorations.markings, hobby, quotes,angles,decorations.pathreplacing}
          % usepgflibrary{shapes.geometric}
          %usepackage{xcolor}


          begin{document}

          begin{figure}[ht]

          centering

          begin{tikzpicture}[line width=1pt]
          begin{axis}[scale=1.5,
          color= black,
          xmin=-1,
          xmax=7.9,
          ymin=-1,
          ymax=2,
          axis equal image,
          axis lines=middle,
          font=scriptsize,
          xtick distance=1,
          ytick distance=1,
          %xticklabels={},
          %yticklabels={},
          inner axis line style={stealth-stealth},
          xlabel = {$x$},
          ylabel = {$f(x)$},
          ticks=none,
          ]
          addplot[black, opacity = 0, domain=0:10, name path = 1]{0};

          addplot[Tan, smooth, domain=0.01:7.5, samples = 300, name path=2, thick] {sin(deg(x))/x};

          addplot[Tan, fill opacity=0.25] fill between [of=1 and 2,soft clip={domain=0:3.1415}];

          end{axis}
          end{tikzpicture}
          caption{Integrating $sin(x)/x$ from $0 le x < infty$.}
          label{1}
          end{figure}
          end{document}


          enter image description here






          share|improve this answer















          The culprit is scale=1.5, which you should pass to the axis, and not to the tikzpicture. I guess you confuse pgfplots otherwise, see this answer. If you wish to have a core-level explanation, I am afraid I cannot provide it, but given this answer one of my first guesses was to change the position of scale, and it seems to work. Notice also that the pgfplots library fillbetween loads intersections, but a slightly advanced version, so you should not load intersections (again). I also removed tkz-euclide and unused libraries (in order to keep the code tidy), but you may resurrect them and the code still works as it should.



          PassOptionsToPackage{usenames,dvipsnames,table,x11names}{xcolor}
          documentclass[a4paper, 12pt]{article}
          usepackage{amsmath}
          usepackage{amssymb}
          usepackage{pgfplots}
          %usepackage{tkz-euclide}
          pgfplotsset{compat=1.15}
          usepgfplotslibrary{%polar,colormaps,
          fillbetween}
          % usetikzlibrary{arrows,shadows,positioning, calc, decorations.markings, hobby, quotes,angles,decorations.pathreplacing}
          % usepgflibrary{shapes.geometric}
          %usepackage{xcolor}


          begin{document}

          begin{figure}[ht]

          centering

          begin{tikzpicture}[line width=1pt]
          begin{axis}[scale=1.5,
          color= black,
          xmin=-1,
          xmax=7.9,
          ymin=-1,
          ymax=2,
          axis equal image,
          axis lines=middle,
          font=scriptsize,
          xtick distance=1,
          ytick distance=1,
          %xticklabels={},
          %yticklabels={},
          inner axis line style={stealth-stealth},
          xlabel = {$x$},
          ylabel = {$f(x)$},
          ticks=none,
          ]
          addplot[black, opacity = 0, domain=0:10, name path = 1]{0};

          addplot[Tan, smooth, domain=0.01:7.5, samples = 300, name path=2, thick] {sin(deg(x))/x};

          addplot[Tan, fill opacity=0.25] fill between [of=1 and 2,soft clip={domain=0:3.1415}];

          end{axis}
          end{tikzpicture}
          caption{Integrating $sin(x)/x$ from $0 le x < infty$.}
          label{1}
          end{figure}
          end{document}


          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 9 hours ago

























          answered 10 hours ago









          marmotmarmot

          106k4127242




          106k4127242








          • 2





            Perfect, thanks. I'm always curious about small issues like this because the solution is not at all obvious.

            – Aiden Kenny
            8 hours ago














          • 2





            Perfect, thanks. I'm always curious about small issues like this because the solution is not at all obvious.

            – Aiden Kenny
            8 hours ago








          2




          2





          Perfect, thanks. I'm always curious about small issues like this because the solution is not at all obvious.

          – Aiden Kenny
          8 hours ago





          Perfect, thanks. I'm always curious about small issues like this because the solution is not at all obvious.

          – Aiden Kenny
          8 hours ago


















          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.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f477872%2ffilling-in-area-under-curve-causes-alignment-issues%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

          香粉寮

          GameSpot