Draw multiple arrows from one node to many others using a palette of colors
This is a continuation of a previous question: Draw a set of arrows using a palette of colors.
What I want
I want to draw multiple arrows starting from one node to more than one. Each arrow that starts in the same node must have the same color; but another node must have the following color (with its arrows of the same color), and so on.
You have to achieve the following in the most automatically possible way:
What I have done
This MWE is adapted for a better manipulation of the answer to that question:
documentclass{article}
usepackage{tikz}
newcommandtotalnodes{5} % Define the total of nodes-1
begin{document}
begin{tikzpicture} % From https://tex.stackexchange.com/a/480466/152550
foreach X in {0,...,totalnodes} {
node[circle,draw,name=aX] at (0,X) {};
node[circle,draw,name=bX] at (1,X) {};
% [actual node] * [0.75 (limits the final color to purple)] * 1/totalsubjects
pgfmathsetmacro{huenum}{X*0.75*(1/totalnodes)}
definecolor{mycolor}{hsb}{huenum,1,1}
draw[-latex,mycolor] (aX) to (bX);
}
end{tikzpicture}
end{document}
As you can see, I am not able to find an algorithm capable of adding more arrows that come from the same node.
My idea was to make a recursive algorithm that goes through some of the nodes in which I wanted to get the arrow, but I do not know how to jump from node 0
to 2
and then to 5
and so on.
For example, to start with something I tried to change draw[-latex,mycolor] (aX) to (bX);
to draw[-latex,mycolor] (aX) to (b$X-0$);
(new line) draw[-latex,mycolor] (aX) to (b$X-1$);
(new line) draw[-latex,mycolor] (aX) to (b$X-2$);
etc. but the compiler gives errors (as expected).
Thanks!!
tikz-pgf errors color
add a comment |
This is a continuation of a previous question: Draw a set of arrows using a palette of colors.
What I want
I want to draw multiple arrows starting from one node to more than one. Each arrow that starts in the same node must have the same color; but another node must have the following color (with its arrows of the same color), and so on.
You have to achieve the following in the most automatically possible way:
What I have done
This MWE is adapted for a better manipulation of the answer to that question:
documentclass{article}
usepackage{tikz}
newcommandtotalnodes{5} % Define the total of nodes-1
begin{document}
begin{tikzpicture} % From https://tex.stackexchange.com/a/480466/152550
foreach X in {0,...,totalnodes} {
node[circle,draw,name=aX] at (0,X) {};
node[circle,draw,name=bX] at (1,X) {};
% [actual node] * [0.75 (limits the final color to purple)] * 1/totalsubjects
pgfmathsetmacro{huenum}{X*0.75*(1/totalnodes)}
definecolor{mycolor}{hsb}{huenum,1,1}
draw[-latex,mycolor] (aX) to (bX);
}
end{tikzpicture}
end{document}
As you can see, I am not able to find an algorithm capable of adding more arrows that come from the same node.
My idea was to make a recursive algorithm that goes through some of the nodes in which I wanted to get the arrow, but I do not know how to jump from node 0
to 2
and then to 5
and so on.
For example, to start with something I tried to change draw[-latex,mycolor] (aX) to (bX);
to draw[-latex,mycolor] (aX) to (b$X-0$);
(new line) draw[-latex,mycolor] (aX) to (b$X-1$);
(new line) draw[-latex,mycolor] (aX) to (b$X-2$);
etc. but the compiler gives errors (as expected).
Thanks!!
tikz-pgf errors color
add a comment |
This is a continuation of a previous question: Draw a set of arrows using a palette of colors.
What I want
I want to draw multiple arrows starting from one node to more than one. Each arrow that starts in the same node must have the same color; but another node must have the following color (with its arrows of the same color), and so on.
You have to achieve the following in the most automatically possible way:
What I have done
This MWE is adapted for a better manipulation of the answer to that question:
documentclass{article}
usepackage{tikz}
newcommandtotalnodes{5} % Define the total of nodes-1
begin{document}
begin{tikzpicture} % From https://tex.stackexchange.com/a/480466/152550
foreach X in {0,...,totalnodes} {
node[circle,draw,name=aX] at (0,X) {};
node[circle,draw,name=bX] at (1,X) {};
% [actual node] * [0.75 (limits the final color to purple)] * 1/totalsubjects
pgfmathsetmacro{huenum}{X*0.75*(1/totalnodes)}
definecolor{mycolor}{hsb}{huenum,1,1}
draw[-latex,mycolor] (aX) to (bX);
}
end{tikzpicture}
end{document}
As you can see, I am not able to find an algorithm capable of adding more arrows that come from the same node.
My idea was to make a recursive algorithm that goes through some of the nodes in which I wanted to get the arrow, but I do not know how to jump from node 0
to 2
and then to 5
and so on.
For example, to start with something I tried to change draw[-latex,mycolor] (aX) to (bX);
to draw[-latex,mycolor] (aX) to (b$X-0$);
(new line) draw[-latex,mycolor] (aX) to (b$X-1$);
(new line) draw[-latex,mycolor] (aX) to (b$X-2$);
etc. but the compiler gives errors (as expected).
Thanks!!
tikz-pgf errors color
This is a continuation of a previous question: Draw a set of arrows using a palette of colors.
What I want
I want to draw multiple arrows starting from one node to more than one. Each arrow that starts in the same node must have the same color; but another node must have the following color (with its arrows of the same color), and so on.
You have to achieve the following in the most automatically possible way:
What I have done
This MWE is adapted for a better manipulation of the answer to that question:
documentclass{article}
usepackage{tikz}
newcommandtotalnodes{5} % Define the total of nodes-1
begin{document}
begin{tikzpicture} % From https://tex.stackexchange.com/a/480466/152550
foreach X in {0,...,totalnodes} {
node[circle,draw,name=aX] at (0,X) {};
node[circle,draw,name=bX] at (1,X) {};
% [actual node] * [0.75 (limits the final color to purple)] * 1/totalsubjects
pgfmathsetmacro{huenum}{X*0.75*(1/totalnodes)}
definecolor{mycolor}{hsb}{huenum,1,1}
draw[-latex,mycolor] (aX) to (bX);
}
end{tikzpicture}
end{document}
As you can see, I am not able to find an algorithm capable of adding more arrows that come from the same node.
My idea was to make a recursive algorithm that goes through some of the nodes in which I wanted to get the arrow, but I do not know how to jump from node 0
to 2
and then to 5
and so on.
For example, to start with something I tried to change draw[-latex,mycolor] (aX) to (bX);
to draw[-latex,mycolor] (aX) to (b$X-0$);
(new line) draw[-latex,mycolor] (aX) to (b$X-1$);
(new line) draw[-latex,mycolor] (aX) to (b$X-2$);
etc. but the compiler gives errors (as expected).
Thanks!!
tikz-pgf errors color
tikz-pgf errors color
asked Mar 21 at 5:29
manoooohmanooooh
1,1631517
1,1631517
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Something like this? You specify the connections in a list. The 0th entry specifies that the 0th a node is to be connected with the b nodes 2 and 3, and so on.
documentclass{article}
usepackage{tikz}
newcommandtotalnodes{5} % Define the total of nodes-1
begin{document}
begin{tikzpicture} % From https://tex.stackexchange.com/a/480466/152550
defLstCon{{"{2,3}","{1}","{2}","{2,3,4,5}","{4}","{1,4,5}"}}
foreach X in {0,...,totalnodes} {
node[circle,draw,name=aX] at (0,X) {};
node[circle,draw,name=bX] at (1,X) {};
}
foreach X in {0,...,totalnodes} {
pgfmathsetmacro{huenum}{X*0.75*(1/totalnodes)}
definecolor{mycolor}{hsb}{huenum,1,1}
pgfmathsetmacro{mylst}{LstCon[X]}
foreach Y in mylst
{draw[-latex,mycolor] (aX) to (bY);}
}
end{tikzpicture}
end{document}
add a comment |
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%2f480622%2fdraw-multiple-arrows-from-one-node-to-many-others-using-a-palette-of-colors%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
Something like this? You specify the connections in a list. The 0th entry specifies that the 0th a node is to be connected with the b nodes 2 and 3, and so on.
documentclass{article}
usepackage{tikz}
newcommandtotalnodes{5} % Define the total of nodes-1
begin{document}
begin{tikzpicture} % From https://tex.stackexchange.com/a/480466/152550
defLstCon{{"{2,3}","{1}","{2}","{2,3,4,5}","{4}","{1,4,5}"}}
foreach X in {0,...,totalnodes} {
node[circle,draw,name=aX] at (0,X) {};
node[circle,draw,name=bX] at (1,X) {};
}
foreach X in {0,...,totalnodes} {
pgfmathsetmacro{huenum}{X*0.75*(1/totalnodes)}
definecolor{mycolor}{hsb}{huenum,1,1}
pgfmathsetmacro{mylst}{LstCon[X]}
foreach Y in mylst
{draw[-latex,mycolor] (aX) to (bY);}
}
end{tikzpicture}
end{document}
add a comment |
Something like this? You specify the connections in a list. The 0th entry specifies that the 0th a node is to be connected with the b nodes 2 and 3, and so on.
documentclass{article}
usepackage{tikz}
newcommandtotalnodes{5} % Define the total of nodes-1
begin{document}
begin{tikzpicture} % From https://tex.stackexchange.com/a/480466/152550
defLstCon{{"{2,3}","{1}","{2}","{2,3,4,5}","{4}","{1,4,5}"}}
foreach X in {0,...,totalnodes} {
node[circle,draw,name=aX] at (0,X) {};
node[circle,draw,name=bX] at (1,X) {};
}
foreach X in {0,...,totalnodes} {
pgfmathsetmacro{huenum}{X*0.75*(1/totalnodes)}
definecolor{mycolor}{hsb}{huenum,1,1}
pgfmathsetmacro{mylst}{LstCon[X]}
foreach Y in mylst
{draw[-latex,mycolor] (aX) to (bY);}
}
end{tikzpicture}
end{document}
add a comment |
Something like this? You specify the connections in a list. The 0th entry specifies that the 0th a node is to be connected with the b nodes 2 and 3, and so on.
documentclass{article}
usepackage{tikz}
newcommandtotalnodes{5} % Define the total of nodes-1
begin{document}
begin{tikzpicture} % From https://tex.stackexchange.com/a/480466/152550
defLstCon{{"{2,3}","{1}","{2}","{2,3,4,5}","{4}","{1,4,5}"}}
foreach X in {0,...,totalnodes} {
node[circle,draw,name=aX] at (0,X) {};
node[circle,draw,name=bX] at (1,X) {};
}
foreach X in {0,...,totalnodes} {
pgfmathsetmacro{huenum}{X*0.75*(1/totalnodes)}
definecolor{mycolor}{hsb}{huenum,1,1}
pgfmathsetmacro{mylst}{LstCon[X]}
foreach Y in mylst
{draw[-latex,mycolor] (aX) to (bY);}
}
end{tikzpicture}
end{document}
Something like this? You specify the connections in a list. The 0th entry specifies that the 0th a node is to be connected with the b nodes 2 and 3, and so on.
documentclass{article}
usepackage{tikz}
newcommandtotalnodes{5} % Define the total of nodes-1
begin{document}
begin{tikzpicture} % From https://tex.stackexchange.com/a/480466/152550
defLstCon{{"{2,3}","{1}","{2}","{2,3,4,5}","{4}","{1,4,5}"}}
foreach X in {0,...,totalnodes} {
node[circle,draw,name=aX] at (0,X) {};
node[circle,draw,name=bX] at (1,X) {};
}
foreach X in {0,...,totalnodes} {
pgfmathsetmacro{huenum}{X*0.75*(1/totalnodes)}
definecolor{mycolor}{hsb}{huenum,1,1}
pgfmathsetmacro{mylst}{LstCon[X]}
foreach Y in mylst
{draw[-latex,mycolor] (aX) to (bY);}
}
end{tikzpicture}
end{document}
answered Mar 21 at 5:51
marmotmarmot
113k5145275
113k5145275
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%2f480622%2fdraw-multiple-arrows-from-one-node-to-many-others-using-a-palette-of-colors%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