Coloring edges of a polygon differently












0















I would like to draw a regular 21 polygon, where the edges are labelled and have arrows in the middle using different colors. This is what I have done so far
enter image description here
using this code



    documentclass[margin=0pt]{standalone}
%---------------------------- Tikz Libraries ------------------------------%
usepackage{ifthen}
usepackage{tikz}
usetikzlibrary{shapes.geometric}
usetikzlibrary{decorations, decorations.markings}
usetikzlibrary{arrows, arrows.meta}

%========================== Middle & pointing arrows ==========================%
%-------------------------------------------------------------------------------%
% usage: draw[->-] or draw[->-=6pt red 1]
%-------------------------------------------------------------------------------%
tikzset{ ->-/.style args={#1 #2 #3}{
decoration={markings,mark= at position 0.5 with {arrow{stealth}}, },
postaction={decorate}, },
->-/.default= {0.5 6pt black }}


%========================== Middle & pointing arrows ==========================%
%-------------------------------------------------------------------------------%
% usage: draw[-<-] path; or draw[-<-=6pt red 1] path;
%-------------------------------------------------------------------------------%
tikzset{ -<-/.style args={#1 #2 #3}{
decoration={markings,mark= at position 0.5 with {arrow[>=stealth]{<}}, },
postaction={decorate}, },
-<-/.default= {0.5 6pt black }}


begin{document}

begin{tikzpicture}

node[fill=gray!10] (pol) [
draw,
minimum size=0.9textwidth,
regular polygon, regular polygon sides=21,
rotate=270,
]{};
foreach x/y/i in {1/2/1,5/6/2,9/10/3} %alpha's
path[red,auto=right, ->-]
(pol.corner x)--(pol.corner y)
node[red,midway]{$alpha_{i}$};
foreach x/y/i in {3/4/1,7/8/2,11/12/3} %inverse alpha's
path[red,auto=right, -<-]
(pol.corner x)--(pol.corner y)
node[red,midway]{$alpha_{i}$};
foreach x/y/i in {2/3/1,6/7/2,10/11/3} %beta's
path[blue,auto=right, ->-]
(pol.corner x)--(pol.corner y)
node[blue,midway]{$beta_{i}$};
foreach x/y/i in {4/5/1,8/9/2,12/13/3} %inverse beta's
path[blue,auto=right, -<-]
(pol.corner x)--(pol.corner y)
node[blue,midway]{$beta_{i}$};
foreach x/y/i in {13/14/1, 16/17/2,19/20/3} %xi's
path[teal,auto=right,->-]
(pol.corner x)--(pol.corner y)
node[teal,midway]{$xi_ {i}$};
foreach x/y/i in {15/16/1,18/19/2,21/1/3} %inverse xi's
path[teal,auto=right,-<-]
(pol.corner x)--(pol.corner y)
node[teal,midway]{$xi_{i}$};
foreach x/y/i in {14/15/1,17/18/2,20/21/3} %rho's
path[violet,auto=right,->-]
(pol.corner x)--(pol.corner y)
node[violet,midway]{$rho_{i}$};
end{tikzpicture}
end{document}


Now, I would also like to color the edges of the polygon corresponding to the labels. But I am just able to color all edges in the same color. How can I do that?










share|improve this question





























    0















    I would like to draw a regular 21 polygon, where the edges are labelled and have arrows in the middle using different colors. This is what I have done so far
    enter image description here
    using this code



        documentclass[margin=0pt]{standalone}
    %---------------------------- Tikz Libraries ------------------------------%
    usepackage{ifthen}
    usepackage{tikz}
    usetikzlibrary{shapes.geometric}
    usetikzlibrary{decorations, decorations.markings}
    usetikzlibrary{arrows, arrows.meta}

    %========================== Middle & pointing arrows ==========================%
    %-------------------------------------------------------------------------------%
    % usage: draw[->-] or draw[->-=6pt red 1]
    %-------------------------------------------------------------------------------%
    tikzset{ ->-/.style args={#1 #2 #3}{
    decoration={markings,mark= at position 0.5 with {arrow{stealth}}, },
    postaction={decorate}, },
    ->-/.default= {0.5 6pt black }}


    %========================== Middle & pointing arrows ==========================%
    %-------------------------------------------------------------------------------%
    % usage: draw[-<-] path; or draw[-<-=6pt red 1] path;
    %-------------------------------------------------------------------------------%
    tikzset{ -<-/.style args={#1 #2 #3}{
    decoration={markings,mark= at position 0.5 with {arrow[>=stealth]{<}}, },
    postaction={decorate}, },
    -<-/.default= {0.5 6pt black }}


    begin{document}

    begin{tikzpicture}

    node[fill=gray!10] (pol) [
    draw,
    minimum size=0.9textwidth,
    regular polygon, regular polygon sides=21,
    rotate=270,
    ]{};
    foreach x/y/i in {1/2/1,5/6/2,9/10/3} %alpha's
    path[red,auto=right, ->-]
    (pol.corner x)--(pol.corner y)
    node[red,midway]{$alpha_{i}$};
    foreach x/y/i in {3/4/1,7/8/2,11/12/3} %inverse alpha's
    path[red,auto=right, -<-]
    (pol.corner x)--(pol.corner y)
    node[red,midway]{$alpha_{i}$};
    foreach x/y/i in {2/3/1,6/7/2,10/11/3} %beta's
    path[blue,auto=right, ->-]
    (pol.corner x)--(pol.corner y)
    node[blue,midway]{$beta_{i}$};
    foreach x/y/i in {4/5/1,8/9/2,12/13/3} %inverse beta's
    path[blue,auto=right, -<-]
    (pol.corner x)--(pol.corner y)
    node[blue,midway]{$beta_{i}$};
    foreach x/y/i in {13/14/1, 16/17/2,19/20/3} %xi's
    path[teal,auto=right,->-]
    (pol.corner x)--(pol.corner y)
    node[teal,midway]{$xi_ {i}$};
    foreach x/y/i in {15/16/1,18/19/2,21/1/3} %inverse xi's
    path[teal,auto=right,-<-]
    (pol.corner x)--(pol.corner y)
    node[teal,midway]{$xi_{i}$};
    foreach x/y/i in {14/15/1,17/18/2,20/21/3} %rho's
    path[violet,auto=right,->-]
    (pol.corner x)--(pol.corner y)
    node[violet,midway]{$rho_{i}$};
    end{tikzpicture}
    end{document}


    Now, I would also like to color the edges of the polygon corresponding to the labels. But I am just able to color all edges in the same color. How can I do that?










    share|improve this question



























      0












      0








      0








      I would like to draw a regular 21 polygon, where the edges are labelled and have arrows in the middle using different colors. This is what I have done so far
      enter image description here
      using this code



          documentclass[margin=0pt]{standalone}
      %---------------------------- Tikz Libraries ------------------------------%
      usepackage{ifthen}
      usepackage{tikz}
      usetikzlibrary{shapes.geometric}
      usetikzlibrary{decorations, decorations.markings}
      usetikzlibrary{arrows, arrows.meta}

      %========================== Middle & pointing arrows ==========================%
      %-------------------------------------------------------------------------------%
      % usage: draw[->-] or draw[->-=6pt red 1]
      %-------------------------------------------------------------------------------%
      tikzset{ ->-/.style args={#1 #2 #3}{
      decoration={markings,mark= at position 0.5 with {arrow{stealth}}, },
      postaction={decorate}, },
      ->-/.default= {0.5 6pt black }}


      %========================== Middle & pointing arrows ==========================%
      %-------------------------------------------------------------------------------%
      % usage: draw[-<-] path; or draw[-<-=6pt red 1] path;
      %-------------------------------------------------------------------------------%
      tikzset{ -<-/.style args={#1 #2 #3}{
      decoration={markings,mark= at position 0.5 with {arrow[>=stealth]{<}}, },
      postaction={decorate}, },
      -<-/.default= {0.5 6pt black }}


      begin{document}

      begin{tikzpicture}

      node[fill=gray!10] (pol) [
      draw,
      minimum size=0.9textwidth,
      regular polygon, regular polygon sides=21,
      rotate=270,
      ]{};
      foreach x/y/i in {1/2/1,5/6/2,9/10/3} %alpha's
      path[red,auto=right, ->-]
      (pol.corner x)--(pol.corner y)
      node[red,midway]{$alpha_{i}$};
      foreach x/y/i in {3/4/1,7/8/2,11/12/3} %inverse alpha's
      path[red,auto=right, -<-]
      (pol.corner x)--(pol.corner y)
      node[red,midway]{$alpha_{i}$};
      foreach x/y/i in {2/3/1,6/7/2,10/11/3} %beta's
      path[blue,auto=right, ->-]
      (pol.corner x)--(pol.corner y)
      node[blue,midway]{$beta_{i}$};
      foreach x/y/i in {4/5/1,8/9/2,12/13/3} %inverse beta's
      path[blue,auto=right, -<-]
      (pol.corner x)--(pol.corner y)
      node[blue,midway]{$beta_{i}$};
      foreach x/y/i in {13/14/1, 16/17/2,19/20/3} %xi's
      path[teal,auto=right,->-]
      (pol.corner x)--(pol.corner y)
      node[teal,midway]{$xi_ {i}$};
      foreach x/y/i in {15/16/1,18/19/2,21/1/3} %inverse xi's
      path[teal,auto=right,-<-]
      (pol.corner x)--(pol.corner y)
      node[teal,midway]{$xi_{i}$};
      foreach x/y/i in {14/15/1,17/18/2,20/21/3} %rho's
      path[violet,auto=right,->-]
      (pol.corner x)--(pol.corner y)
      node[violet,midway]{$rho_{i}$};
      end{tikzpicture}
      end{document}


      Now, I would also like to color the edges of the polygon corresponding to the labels. But I am just able to color all edges in the same color. How can I do that?










      share|improve this question
















      I would like to draw a regular 21 polygon, where the edges are labelled and have arrows in the middle using different colors. This is what I have done so far
      enter image description here
      using this code



          documentclass[margin=0pt]{standalone}
      %---------------------------- Tikz Libraries ------------------------------%
      usepackage{ifthen}
      usepackage{tikz}
      usetikzlibrary{shapes.geometric}
      usetikzlibrary{decorations, decorations.markings}
      usetikzlibrary{arrows, arrows.meta}

      %========================== Middle & pointing arrows ==========================%
      %-------------------------------------------------------------------------------%
      % usage: draw[->-] or draw[->-=6pt red 1]
      %-------------------------------------------------------------------------------%
      tikzset{ ->-/.style args={#1 #2 #3}{
      decoration={markings,mark= at position 0.5 with {arrow{stealth}}, },
      postaction={decorate}, },
      ->-/.default= {0.5 6pt black }}


      %========================== Middle & pointing arrows ==========================%
      %-------------------------------------------------------------------------------%
      % usage: draw[-<-] path; or draw[-<-=6pt red 1] path;
      %-------------------------------------------------------------------------------%
      tikzset{ -<-/.style args={#1 #2 #3}{
      decoration={markings,mark= at position 0.5 with {arrow[>=stealth]{<}}, },
      postaction={decorate}, },
      -<-/.default= {0.5 6pt black }}


      begin{document}

      begin{tikzpicture}

      node[fill=gray!10] (pol) [
      draw,
      minimum size=0.9textwidth,
      regular polygon, regular polygon sides=21,
      rotate=270,
      ]{};
      foreach x/y/i in {1/2/1,5/6/2,9/10/3} %alpha's
      path[red,auto=right, ->-]
      (pol.corner x)--(pol.corner y)
      node[red,midway]{$alpha_{i}$};
      foreach x/y/i in {3/4/1,7/8/2,11/12/3} %inverse alpha's
      path[red,auto=right, -<-]
      (pol.corner x)--(pol.corner y)
      node[red,midway]{$alpha_{i}$};
      foreach x/y/i in {2/3/1,6/7/2,10/11/3} %beta's
      path[blue,auto=right, ->-]
      (pol.corner x)--(pol.corner y)
      node[blue,midway]{$beta_{i}$};
      foreach x/y/i in {4/5/1,8/9/2,12/13/3} %inverse beta's
      path[blue,auto=right, -<-]
      (pol.corner x)--(pol.corner y)
      node[blue,midway]{$beta_{i}$};
      foreach x/y/i in {13/14/1, 16/17/2,19/20/3} %xi's
      path[teal,auto=right,->-]
      (pol.corner x)--(pol.corner y)
      node[teal,midway]{$xi_ {i}$};
      foreach x/y/i in {15/16/1,18/19/2,21/1/3} %inverse xi's
      path[teal,auto=right,-<-]
      (pol.corner x)--(pol.corner y)
      node[teal,midway]{$xi_{i}$};
      foreach x/y/i in {14/15/1,17/18/2,20/21/3} %rho's
      path[violet,auto=right,->-]
      (pol.corner x)--(pol.corner y)
      node[violet,midway]{$rho_{i}$};
      end{tikzpicture}
      end{document}


      Now, I would also like to color the edges of the polygon corresponding to the labels. But I am just able to color all edges in the same color. How can I do that?







      tikz-pgf color polygon






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 8 at 10:35









      Bernard

      167k769194




      167k769194










      asked Jan 8 at 10:04









      mathstackusermathstackuser

      1996




      1996






















          1 Answer
          1






          active

          oldest

          votes


















          1














          like this:



          enter image description here



          for above image i made the following changes in mwe which you provide in question:




          • delete option draw in polygon style definition

          • all path in loops replace with draw






          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',
            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%2f469113%2fcoloring-edges-of-a-polygon-differently%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









            1














            like this:



            enter image description here



            for above image i made the following changes in mwe which you provide in question:




            • delete option draw in polygon style definition

            • all path in loops replace with draw






            share|improve this answer




























              1














              like this:



              enter image description here



              for above image i made the following changes in mwe which you provide in question:




              • delete option draw in polygon style definition

              • all path in loops replace with draw






              share|improve this answer


























                1












                1








                1







                like this:



                enter image description here



                for above image i made the following changes in mwe which you provide in question:




                • delete option draw in polygon style definition

                • all path in loops replace with draw






                share|improve this answer













                like this:



                enter image description here



                for above image i made the following changes in mwe which you provide in question:




                • delete option draw in polygon style definition

                • all path in loops replace with draw







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 8 at 10:30









                ZarkoZarko

                122k865160




                122k865160






























                    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%2f469113%2fcoloring-edges-of-a-polygon-differently%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

                    How to send String Array data to Server using php in android

                    Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

                    Is anime1.com a legal site for watching anime?