Fill area between curves with tikzfillbetween

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











up vote
2
down vote

favorite












I need to fill the area between a few curves with tikzfillbetween, but I don't want the inner circle to be filled.



documentclassstandalone
usepackagetikz
usepackagepgfplots
usetikzlibrarypatterns
pgfplotssetcompat=1.10
usepgfplotslibraryfillbetween
begindocument

begintikzpicture[scale=1]
defR1
defs0.2

draw [black, line width=1pt,samples=100,domain=0:2*pi, name path=A]
plot (R*cos(x r), R*sin(x r));

draw [black, line width=1pt,samples=100,domain=-pi/6:pi/6, name path=B]
plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

draw [black, line width=1pt,samples=100,domain=pi/6:pi/2, name path=C]
plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

draw [black, line width=1pt,samples=100,domain=pi/2:5/6*pi, name path=D]
plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

draw [black, line width=1pt,samples=100,domain=5*pi/6:7*pi/6, name path=E]
plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

draw [black, line width=1pt,samples=100,domain=7*pi/6:3*pi/2, name path=F]
plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

draw [black, line width=1pt,samples=100,domain=3*pi/2:11*pi/6, name path=G]
plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

tikzfillbetween[of=A and B]blue;
tikzfillbetween[of=A and C]red;
tikzfillbetween[of=A and D]blue;
tikzfillbetween[of=A and E]red;
tikzfillbetween[of=A and F]blue;
tikzfillbetween[of=A and G]red;

endtikzpicture

enddocument









share|improve this question

























    up vote
    2
    down vote

    favorite












    I need to fill the area between a few curves with tikzfillbetween, but I don't want the inner circle to be filled.



    documentclassstandalone
    usepackagetikz
    usepackagepgfplots
    usetikzlibrarypatterns
    pgfplotssetcompat=1.10
    usepgfplotslibraryfillbetween
    begindocument

    begintikzpicture[scale=1]
    defR1
    defs0.2

    draw [black, line width=1pt,samples=100,domain=0:2*pi, name path=A]
    plot (R*cos(x r), R*sin(x r));

    draw [black, line width=1pt,samples=100,domain=-pi/6:pi/6, name path=B]
    plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

    draw [black, line width=1pt,samples=100,domain=pi/6:pi/2, name path=C]
    plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

    draw [black, line width=1pt,samples=100,domain=pi/2:5/6*pi, name path=D]
    plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

    draw [black, line width=1pt,samples=100,domain=5*pi/6:7*pi/6, name path=E]
    plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

    draw [black, line width=1pt,samples=100,domain=7*pi/6:3*pi/2, name path=F]
    plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

    draw [black, line width=1pt,samples=100,domain=3*pi/2:11*pi/6, name path=G]
    plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

    tikzfillbetween[of=A and B]blue;
    tikzfillbetween[of=A and C]red;
    tikzfillbetween[of=A and D]blue;
    tikzfillbetween[of=A and E]red;
    tikzfillbetween[of=A and F]blue;
    tikzfillbetween[of=A and G]red;

    endtikzpicture

    enddocument









    share|improve this question























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I need to fill the area between a few curves with tikzfillbetween, but I don't want the inner circle to be filled.



      documentclassstandalone
      usepackagetikz
      usepackagepgfplots
      usetikzlibrarypatterns
      pgfplotssetcompat=1.10
      usepgfplotslibraryfillbetween
      begindocument

      begintikzpicture[scale=1]
      defR1
      defs0.2

      draw [black, line width=1pt,samples=100,domain=0:2*pi, name path=A]
      plot (R*cos(x r), R*sin(x r));

      draw [black, line width=1pt,samples=100,domain=-pi/6:pi/6, name path=B]
      plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

      draw [black, line width=1pt,samples=100,domain=pi/6:pi/2, name path=C]
      plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

      draw [black, line width=1pt,samples=100,domain=pi/2:5/6*pi, name path=D]
      plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

      draw [black, line width=1pt,samples=100,domain=5*pi/6:7*pi/6, name path=E]
      plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

      draw [black, line width=1pt,samples=100,domain=7*pi/6:3*pi/2, name path=F]
      plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

      draw [black, line width=1pt,samples=100,domain=3*pi/2:11*pi/6, name path=G]
      plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

      tikzfillbetween[of=A and B]blue;
      tikzfillbetween[of=A and C]red;
      tikzfillbetween[of=A and D]blue;
      tikzfillbetween[of=A and E]red;
      tikzfillbetween[of=A and F]blue;
      tikzfillbetween[of=A and G]red;

      endtikzpicture

      enddocument









      share|improve this question













      I need to fill the area between a few curves with tikzfillbetween, but I don't want the inner circle to be filled.



      documentclassstandalone
      usepackagetikz
      usepackagepgfplots
      usetikzlibrarypatterns
      pgfplotssetcompat=1.10
      usepgfplotslibraryfillbetween
      begindocument

      begintikzpicture[scale=1]
      defR1
      defs0.2

      draw [black, line width=1pt,samples=100,domain=0:2*pi, name path=A]
      plot (R*cos(x r), R*sin(x r));

      draw [black, line width=1pt,samples=100,domain=-pi/6:pi/6, name path=B]
      plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

      draw [black, line width=1pt,samples=100,domain=pi/6:pi/2, name path=C]
      plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

      draw [black, line width=1pt,samples=100,domain=pi/2:5/6*pi, name path=D]
      plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

      draw [black, line width=1pt,samples=100,domain=5*pi/6:7*pi/6, name path=E]
      plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

      draw [black, line width=1pt,samples=100,domain=7*pi/6:3*pi/2, name path=F]
      plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

      draw [black, line width=1pt,samples=100,domain=3*pi/2:11*pi/6, name path=G]
      plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

      tikzfillbetween[of=A and B]blue;
      tikzfillbetween[of=A and C]red;
      tikzfillbetween[of=A and D]blue;
      tikzfillbetween[of=A and E]red;
      tikzfillbetween[of=A and F]blue;
      tikzfillbetween[of=A and G]red;

      endtikzpicture

      enddocument






      tikz-pgf draw






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 4 hours ago









      jlorenzo

      183




      183




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          3
          down vote













          I have never used pgfplots before and I notice that your code consists in making 6 times the same curve by rotating it around the origin. So I used two foreach loops: one to color in blue, the other to color in red with the same code as you.



          This results in:



          plots



          documentclass[border=5mm]standalone
          usepackagetikz
          usepackagepgfplots
          usetikzlibrarypatterns
          pgfplotssetcompat=1.10
          usepgfplotslibraryfillbetween
          begindocument

          begintikzpicture[scale=1]
          defR1
          defs0.2

          foreach d in -pi/6:pi/6,pi/2:5/6*pi,-pi/2:-5*pi/6

          draw [black, line width=1pt,samples=100,domain=d, name path=B]
          plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));
          draw [black, line width=1pt,samples=100,domain=d, name path=A]
          plot (R*cos(x r), R*sin(x r));
          tikzfillbetween[of=B and A]blue;


          foreach d [count=c] in pi/2:pi/6,5*pi/6:7*pi/6,3*pi/2:11*pi/6

          draw [black, line width=1pt,samples=100,domain=d, name path=C]
          plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));
          draw [black, line width=1pt,samples=100,domain=d, name path=A]
          plot (R*cos(x r), R*sin(x r));
          tikzfillbetween[of=A and C]red;


          endtikzpicture

          enddocument





          share|improve this answer




















          • The pgfplots library fillbetween can be used without doing pgfplots stuff, i.e. without using an axis environment. It allows you to fill intersection segments of long paths. (If the task here is just to produce the picture, you only need to fill the inner circle white at the end of the OP's code. I thought the task was to make use of the pgfplots library fillbetween because the OP is loading it. However, who knows. +1)
            – marmot
            2 hours ago










          • @marmot I didn't quite understand your comment. The only thing I did was to trace each of the six lunula separately with the fillbetween library. I didn't try to do what the OP said, I coded the same construction differently to get around its problem. I could have done 120° rotations, it would have resulted in the same result. +1 too :)
            – AndréC
            1 hour ago











          • What I want to say is that with fillbetween you can decompose a long path into small segments for the fills, and you do not have to create a whole lot of additional paths. In this case, this can be done because we know the parametrizations of the segments, in general, however, we do not, and then this library is really useful.
            – marmot
            1 hour ago

















          up vote
          2
          down vote













          You are loading but not really using the pgfplots library fillbetween. In order to achieve what you want, consider filling intersection sequences rather than the full paths. A is very long, and if you fill the full thing, the circle will be filled.



          documentclassstandalone
          usepackagetikz
          usepackagepgfplots
          usetikzlibrarypatterns
          pgfplotssetcompat=1.10
          usepgfplotslibraryfillbetween
          begindocument

          begintikzpicture[scale=1]
          defR1
          defs0.2

          draw [black, line width=1pt,samples=100,domain=0:2*pi, name path=A]
          plot (R*cos(x r), R*sin(x r));

          draw [black, line width=1pt,samples=100,domain=-pi/6:pi/6, name path=B]
          plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

          draw [black, line width=1pt,samples=100,domain=pi/6:pi/2, name path=C]
          plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

          draw [black, line width=1pt,samples=100,domain=pi/2:5/6*pi, name path=D]
          plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

          draw [black, line width=1pt,samples=100,domain=5*pi/6:7*pi/6, name path=E]
          plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

          draw [black, line width=1pt,samples=100,domain=7*pi/6:3*pi/2, name path=F]
          plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

          draw [black, line width=1pt,samples=100,domain=3*pi/2:11*pi/6, name path=G]
          plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

          fill [blue,intersection segments=of=A and B,
          sequence=A0 -- B1[reverse]];
          fill [red,intersection segments=of=A and C,
          sequence=A1 -- B1[reverse]];
          fill [blue,intersection segments=of=A and D,
          sequence=A1 -- B1[reverse]];
          fill [red,intersection segments=of=A and E,
          sequence=A1 -- B1[reverse]];
          fill [blue,intersection segments=of=A and F,
          sequence=A1 -- B1[reverse]];
          fill [red,intersection segments=of=A and G,
          sequence=A1 -- B1[reverse]];

          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: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            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%2f454240%2ffill-area-between-curves-with-tikzfillbetween%23new-answer', 'question_page');

            );

            Post as a guest






























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            3
            down vote













            I have never used pgfplots before and I notice that your code consists in making 6 times the same curve by rotating it around the origin. So I used two foreach loops: one to color in blue, the other to color in red with the same code as you.



            This results in:



            plots



            documentclass[border=5mm]standalone
            usepackagetikz
            usepackagepgfplots
            usetikzlibrarypatterns
            pgfplotssetcompat=1.10
            usepgfplotslibraryfillbetween
            begindocument

            begintikzpicture[scale=1]
            defR1
            defs0.2

            foreach d in -pi/6:pi/6,pi/2:5/6*pi,-pi/2:-5*pi/6

            draw [black, line width=1pt,samples=100,domain=d, name path=B]
            plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));
            draw [black, line width=1pt,samples=100,domain=d, name path=A]
            plot (R*cos(x r), R*sin(x r));
            tikzfillbetween[of=B and A]blue;


            foreach d [count=c] in pi/2:pi/6,5*pi/6:7*pi/6,3*pi/2:11*pi/6

            draw [black, line width=1pt,samples=100,domain=d, name path=C]
            plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));
            draw [black, line width=1pt,samples=100,domain=d, name path=A]
            plot (R*cos(x r), R*sin(x r));
            tikzfillbetween[of=A and C]red;


            endtikzpicture

            enddocument





            share|improve this answer




















            • The pgfplots library fillbetween can be used without doing pgfplots stuff, i.e. without using an axis environment. It allows you to fill intersection segments of long paths. (If the task here is just to produce the picture, you only need to fill the inner circle white at the end of the OP's code. I thought the task was to make use of the pgfplots library fillbetween because the OP is loading it. However, who knows. +1)
              – marmot
              2 hours ago










            • @marmot I didn't quite understand your comment. The only thing I did was to trace each of the six lunula separately with the fillbetween library. I didn't try to do what the OP said, I coded the same construction differently to get around its problem. I could have done 120° rotations, it would have resulted in the same result. +1 too :)
              – AndréC
              1 hour ago











            • What I want to say is that with fillbetween you can decompose a long path into small segments for the fills, and you do not have to create a whole lot of additional paths. In this case, this can be done because we know the parametrizations of the segments, in general, however, we do not, and then this library is really useful.
              – marmot
              1 hour ago














            up vote
            3
            down vote













            I have never used pgfplots before and I notice that your code consists in making 6 times the same curve by rotating it around the origin. So I used two foreach loops: one to color in blue, the other to color in red with the same code as you.



            This results in:



            plots



            documentclass[border=5mm]standalone
            usepackagetikz
            usepackagepgfplots
            usetikzlibrarypatterns
            pgfplotssetcompat=1.10
            usepgfplotslibraryfillbetween
            begindocument

            begintikzpicture[scale=1]
            defR1
            defs0.2

            foreach d in -pi/6:pi/6,pi/2:5/6*pi,-pi/2:-5*pi/6

            draw [black, line width=1pt,samples=100,domain=d, name path=B]
            plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));
            draw [black, line width=1pt,samples=100,domain=d, name path=A]
            plot (R*cos(x r), R*sin(x r));
            tikzfillbetween[of=B and A]blue;


            foreach d [count=c] in pi/2:pi/6,5*pi/6:7*pi/6,3*pi/2:11*pi/6

            draw [black, line width=1pt,samples=100,domain=d, name path=C]
            plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));
            draw [black, line width=1pt,samples=100,domain=d, name path=A]
            plot (R*cos(x r), R*sin(x r));
            tikzfillbetween[of=A and C]red;


            endtikzpicture

            enddocument





            share|improve this answer




















            • The pgfplots library fillbetween can be used without doing pgfplots stuff, i.e. without using an axis environment. It allows you to fill intersection segments of long paths. (If the task here is just to produce the picture, you only need to fill the inner circle white at the end of the OP's code. I thought the task was to make use of the pgfplots library fillbetween because the OP is loading it. However, who knows. +1)
              – marmot
              2 hours ago










            • @marmot I didn't quite understand your comment. The only thing I did was to trace each of the six lunula separately with the fillbetween library. I didn't try to do what the OP said, I coded the same construction differently to get around its problem. I could have done 120° rotations, it would have resulted in the same result. +1 too :)
              – AndréC
              1 hour ago











            • What I want to say is that with fillbetween you can decompose a long path into small segments for the fills, and you do not have to create a whole lot of additional paths. In this case, this can be done because we know the parametrizations of the segments, in general, however, we do not, and then this library is really useful.
              – marmot
              1 hour ago












            up vote
            3
            down vote










            up vote
            3
            down vote









            I have never used pgfplots before and I notice that your code consists in making 6 times the same curve by rotating it around the origin. So I used two foreach loops: one to color in blue, the other to color in red with the same code as you.



            This results in:



            plots



            documentclass[border=5mm]standalone
            usepackagetikz
            usepackagepgfplots
            usetikzlibrarypatterns
            pgfplotssetcompat=1.10
            usepgfplotslibraryfillbetween
            begindocument

            begintikzpicture[scale=1]
            defR1
            defs0.2

            foreach d in -pi/6:pi/6,pi/2:5/6*pi,-pi/2:-5*pi/6

            draw [black, line width=1pt,samples=100,domain=d, name path=B]
            plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));
            draw [black, line width=1pt,samples=100,domain=d, name path=A]
            plot (R*cos(x r), R*sin(x r));
            tikzfillbetween[of=B and A]blue;


            foreach d [count=c] in pi/2:pi/6,5*pi/6:7*pi/6,3*pi/2:11*pi/6

            draw [black, line width=1pt,samples=100,domain=d, name path=C]
            plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));
            draw [black, line width=1pt,samples=100,domain=d, name path=A]
            plot (R*cos(x r), R*sin(x r));
            tikzfillbetween[of=A and C]red;


            endtikzpicture

            enddocument





            share|improve this answer












            I have never used pgfplots before and I notice that your code consists in making 6 times the same curve by rotating it around the origin. So I used two foreach loops: one to color in blue, the other to color in red with the same code as you.



            This results in:



            plots



            documentclass[border=5mm]standalone
            usepackagetikz
            usepackagepgfplots
            usetikzlibrarypatterns
            pgfplotssetcompat=1.10
            usepgfplotslibraryfillbetween
            begindocument

            begintikzpicture[scale=1]
            defR1
            defs0.2

            foreach d in -pi/6:pi/6,pi/2:5/6*pi,-pi/2:-5*pi/6

            draw [black, line width=1pt,samples=100,domain=d, name path=B]
            plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));
            draw [black, line width=1pt,samples=100,domain=d, name path=A]
            plot (R*cos(x r), R*sin(x r));
            tikzfillbetween[of=B and A]blue;


            foreach d [count=c] in pi/2:pi/6,5*pi/6:7*pi/6,3*pi/2:11*pi/6

            draw [black, line width=1pt,samples=100,domain=d, name path=C]
            plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));
            draw [black, line width=1pt,samples=100,domain=d, name path=A]
            plot (R*cos(x r), R*sin(x r));
            tikzfillbetween[of=A and C]red;


            endtikzpicture

            enddocument






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 3 hours ago









            AndréC

            3,481729




            3,481729











            • The pgfplots library fillbetween can be used without doing pgfplots stuff, i.e. without using an axis environment. It allows you to fill intersection segments of long paths. (If the task here is just to produce the picture, you only need to fill the inner circle white at the end of the OP's code. I thought the task was to make use of the pgfplots library fillbetween because the OP is loading it. However, who knows. +1)
              – marmot
              2 hours ago










            • @marmot I didn't quite understand your comment. The only thing I did was to trace each of the six lunula separately with the fillbetween library. I didn't try to do what the OP said, I coded the same construction differently to get around its problem. I could have done 120° rotations, it would have resulted in the same result. +1 too :)
              – AndréC
              1 hour ago











            • What I want to say is that with fillbetween you can decompose a long path into small segments for the fills, and you do not have to create a whole lot of additional paths. In this case, this can be done because we know the parametrizations of the segments, in general, however, we do not, and then this library is really useful.
              – marmot
              1 hour ago
















            • The pgfplots library fillbetween can be used without doing pgfplots stuff, i.e. without using an axis environment. It allows you to fill intersection segments of long paths. (If the task here is just to produce the picture, you only need to fill the inner circle white at the end of the OP's code. I thought the task was to make use of the pgfplots library fillbetween because the OP is loading it. However, who knows. +1)
              – marmot
              2 hours ago










            • @marmot I didn't quite understand your comment. The only thing I did was to trace each of the six lunula separately with the fillbetween library. I didn't try to do what the OP said, I coded the same construction differently to get around its problem. I could have done 120° rotations, it would have resulted in the same result. +1 too :)
              – AndréC
              1 hour ago











            • What I want to say is that with fillbetween you can decompose a long path into small segments for the fills, and you do not have to create a whole lot of additional paths. In this case, this can be done because we know the parametrizations of the segments, in general, however, we do not, and then this library is really useful.
              – marmot
              1 hour ago















            The pgfplots library fillbetween can be used without doing pgfplots stuff, i.e. without using an axis environment. It allows you to fill intersection segments of long paths. (If the task here is just to produce the picture, you only need to fill the inner circle white at the end of the OP's code. I thought the task was to make use of the pgfplots library fillbetween because the OP is loading it. However, who knows. +1)
            – marmot
            2 hours ago




            The pgfplots library fillbetween can be used without doing pgfplots stuff, i.e. without using an axis environment. It allows you to fill intersection segments of long paths. (If the task here is just to produce the picture, you only need to fill the inner circle white at the end of the OP's code. I thought the task was to make use of the pgfplots library fillbetween because the OP is loading it. However, who knows. +1)
            – marmot
            2 hours ago












            @marmot I didn't quite understand your comment. The only thing I did was to trace each of the six lunula separately with the fillbetween library. I didn't try to do what the OP said, I coded the same construction differently to get around its problem. I could have done 120° rotations, it would have resulted in the same result. +1 too :)
            – AndréC
            1 hour ago





            @marmot I didn't quite understand your comment. The only thing I did was to trace each of the six lunula separately with the fillbetween library. I didn't try to do what the OP said, I coded the same construction differently to get around its problem. I could have done 120° rotations, it would have resulted in the same result. +1 too :)
            – AndréC
            1 hour ago













            What I want to say is that with fillbetween you can decompose a long path into small segments for the fills, and you do not have to create a whole lot of additional paths. In this case, this can be done because we know the parametrizations of the segments, in general, however, we do not, and then this library is really useful.
            – marmot
            1 hour ago




            What I want to say is that with fillbetween you can decompose a long path into small segments for the fills, and you do not have to create a whole lot of additional paths. In this case, this can be done because we know the parametrizations of the segments, in general, however, we do not, and then this library is really useful.
            – marmot
            1 hour ago










            up vote
            2
            down vote













            You are loading but not really using the pgfplots library fillbetween. In order to achieve what you want, consider filling intersection sequences rather than the full paths. A is very long, and if you fill the full thing, the circle will be filled.



            documentclassstandalone
            usepackagetikz
            usepackagepgfplots
            usetikzlibrarypatterns
            pgfplotssetcompat=1.10
            usepgfplotslibraryfillbetween
            begindocument

            begintikzpicture[scale=1]
            defR1
            defs0.2

            draw [black, line width=1pt,samples=100,domain=0:2*pi, name path=A]
            plot (R*cos(x r), R*sin(x r));

            draw [black, line width=1pt,samples=100,domain=-pi/6:pi/6, name path=B]
            plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

            draw [black, line width=1pt,samples=100,domain=pi/6:pi/2, name path=C]
            plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

            draw [black, line width=1pt,samples=100,domain=pi/2:5/6*pi, name path=D]
            plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

            draw [black, line width=1pt,samples=100,domain=5*pi/6:7*pi/6, name path=E]
            plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

            draw [black, line width=1pt,samples=100,domain=7*pi/6:3*pi/2, name path=F]
            plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

            draw [black, line width=1pt,samples=100,domain=3*pi/2:11*pi/6, name path=G]
            plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

            fill [blue,intersection segments=of=A and B,
            sequence=A0 -- B1[reverse]];
            fill [red,intersection segments=of=A and C,
            sequence=A1 -- B1[reverse]];
            fill [blue,intersection segments=of=A and D,
            sequence=A1 -- B1[reverse]];
            fill [red,intersection segments=of=A and E,
            sequence=A1 -- B1[reverse]];
            fill [blue,intersection segments=of=A and F,
            sequence=A1 -- B1[reverse]];
            fill [red,intersection segments=of=A and G,
            sequence=A1 -- B1[reverse]];

            endtikzpicture

            enddocument


            enter image description here






            share|improve this answer
























              up vote
              2
              down vote













              You are loading but not really using the pgfplots library fillbetween. In order to achieve what you want, consider filling intersection sequences rather than the full paths. A is very long, and if you fill the full thing, the circle will be filled.



              documentclassstandalone
              usepackagetikz
              usepackagepgfplots
              usetikzlibrarypatterns
              pgfplotssetcompat=1.10
              usepgfplotslibraryfillbetween
              begindocument

              begintikzpicture[scale=1]
              defR1
              defs0.2

              draw [black, line width=1pt,samples=100,domain=0:2*pi, name path=A]
              plot (R*cos(x r), R*sin(x r));

              draw [black, line width=1pt,samples=100,domain=-pi/6:pi/6, name path=B]
              plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

              draw [black, line width=1pt,samples=100,domain=pi/6:pi/2, name path=C]
              plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

              draw [black, line width=1pt,samples=100,domain=pi/2:5/6*pi, name path=D]
              plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

              draw [black, line width=1pt,samples=100,domain=5*pi/6:7*pi/6, name path=E]
              plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

              draw [black, line width=1pt,samples=100,domain=7*pi/6:3*pi/2, name path=F]
              plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

              draw [black, line width=1pt,samples=100,domain=3*pi/2:11*pi/6, name path=G]
              plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

              fill [blue,intersection segments=of=A and B,
              sequence=A0 -- B1[reverse]];
              fill [red,intersection segments=of=A and C,
              sequence=A1 -- B1[reverse]];
              fill [blue,intersection segments=of=A and D,
              sequence=A1 -- B1[reverse]];
              fill [red,intersection segments=of=A and E,
              sequence=A1 -- B1[reverse]];
              fill [blue,intersection segments=of=A and F,
              sequence=A1 -- B1[reverse]];
              fill [red,intersection segments=of=A and G,
              sequence=A1 -- B1[reverse]];

              endtikzpicture

              enddocument


              enter image description here






              share|improve this answer






















                up vote
                2
                down vote










                up vote
                2
                down vote









                You are loading but not really using the pgfplots library fillbetween. In order to achieve what you want, consider filling intersection sequences rather than the full paths. A is very long, and if you fill the full thing, the circle will be filled.



                documentclassstandalone
                usepackagetikz
                usepackagepgfplots
                usetikzlibrarypatterns
                pgfplotssetcompat=1.10
                usepgfplotslibraryfillbetween
                begindocument

                begintikzpicture[scale=1]
                defR1
                defs0.2

                draw [black, line width=1pt,samples=100,domain=0:2*pi, name path=A]
                plot (R*cos(x r), R*sin(x r));

                draw [black, line width=1pt,samples=100,domain=-pi/6:pi/6, name path=B]
                plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

                draw [black, line width=1pt,samples=100,domain=pi/6:pi/2, name path=C]
                plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

                draw [black, line width=1pt,samples=100,domain=pi/2:5/6*pi, name path=D]
                plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

                draw [black, line width=1pt,samples=100,domain=5*pi/6:7*pi/6, name path=E]
                plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

                draw [black, line width=1pt,samples=100,domain=7*pi/6:3*pi/2, name path=F]
                plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

                draw [black, line width=1pt,samples=100,domain=3*pi/2:11*pi/6, name path=G]
                plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

                fill [blue,intersection segments=of=A and B,
                sequence=A0 -- B1[reverse]];
                fill [red,intersection segments=of=A and C,
                sequence=A1 -- B1[reverse]];
                fill [blue,intersection segments=of=A and D,
                sequence=A1 -- B1[reverse]];
                fill [red,intersection segments=of=A and E,
                sequence=A1 -- B1[reverse]];
                fill [blue,intersection segments=of=A and F,
                sequence=A1 -- B1[reverse]];
                fill [red,intersection segments=of=A and G,
                sequence=A1 -- B1[reverse]];

                endtikzpicture

                enddocument


                enter image description here






                share|improve this answer












                You are loading but not really using the pgfplots library fillbetween. In order to achieve what you want, consider filling intersection sequences rather than the full paths. A is very long, and if you fill the full thing, the circle will be filled.



                documentclassstandalone
                usepackagetikz
                usepackagepgfplots
                usetikzlibrarypatterns
                pgfplotssetcompat=1.10
                usepgfplotslibraryfillbetween
                begindocument

                begintikzpicture[scale=1]
                defR1
                defs0.2

                draw [black, line width=1pt,samples=100,domain=0:2*pi, name path=A]
                plot (R*cos(x r), R*sin(x r));

                draw [black, line width=1pt,samples=100,domain=-pi/6:pi/6, name path=B]
                plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

                draw [black, line width=1pt,samples=100,domain=pi/6:pi/2, name path=C]
                plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

                draw [black, line width=1pt,samples=100,domain=pi/2:5/6*pi, name path=D]
                plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

                draw [black, line width=1pt,samples=100,domain=5*pi/6:7*pi/6, name path=E]
                plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

                draw [black, line width=1pt,samples=100,domain=7*pi/6:3*pi/2, name path=F]
                plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

                draw [black, line width=1pt,samples=100,domain=3*pi/2:11*pi/6, name path=G]
                plot ((R + abs(s*cos(3*x r)))*cos(x r), (R + abs(s*cos(3*x r)))*sin(x r));

                fill [blue,intersection segments=of=A and B,
                sequence=A0 -- B1[reverse]];
                fill [red,intersection segments=of=A and C,
                sequence=A1 -- B1[reverse]];
                fill [blue,intersection segments=of=A and D,
                sequence=A1 -- B1[reverse]];
                fill [red,intersection segments=of=A and E,
                sequence=A1 -- B1[reverse]];
                fill [blue,intersection segments=of=A and F,
                sequence=A1 -- B1[reverse]];
                fill [red,intersection segments=of=A and G,
                sequence=A1 -- B1[reverse]];

                endtikzpicture

                enddocument


                enter image description here







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 4 hours ago









                marmot

                63.5k468136




                63.5k468136



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f454240%2ffill-area-between-curves-with-tikzfillbetween%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    Long meetings (6-7 hours a day): Being “babysat” by supervisor

                    Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

                    Confectionery