Coloring edges of a polygon differently
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

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
add a comment |
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

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
add a comment |
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

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
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

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
tikz-pgf color polygon
edited Jan 8 at 10:35
Bernard
167k769194
167k769194
asked Jan 8 at 10:04
mathstackusermathstackuser
1996
1996
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
like this:

for above image i made the following changes in mwe which you provide in question:
- delete option
drawin polygon style definition - all
pathin loops replace withdraw
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
like this:

for above image i made the following changes in mwe which you provide in question:
- delete option
drawin polygon style definition - all
pathin loops replace withdraw
add a comment |
like this:

for above image i made the following changes in mwe which you provide in question:
- delete option
drawin polygon style definition - all
pathin loops replace withdraw
add a comment |
like this:

for above image i made the following changes in mwe which you provide in question:
- delete option
drawin polygon style definition - all
pathin loops replace withdraw
like this:

for above image i made the following changes in mwe which you provide in question:
- delete option
drawin polygon style definition - all
pathin loops replace withdraw
answered Jan 8 at 10:30
ZarkoZarko
122k865160
122k865160
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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