I am involved in a project that includes the creation of arrows.
Making a monocolored figure is a visual problem due to the scarcity of colors, so I came to design a solution that is as automatic as possible with your huge help!
I need to draw n
arrows, so I need n
colors (*).
What kind of color?
Every color is composed by a single color, it is solid, preferably using RGB mode.
Where is the set of colors?
I do not know :D
. Seriously, because of my low knowledge of colors I did not find any place where a range of colors from white to black is available, so I found some alternative ideas:
Monochromatic Color Schemes (w3schools.com):
Rainbow color palette (Pinterest):
Using ColorBrewer
in TikZ
and pgfplots
:
What I want
I see colors as a (finite) tape where depending on the number of pixels we can have more or less (solid) colors. For example, it would be ideal for me to be able to work (in RGB) with Monochromatic Color Schemes (w3schools.com), but:
- The colors have to be arranged in a row and not in a circular shape (like a matrix of
1 x n
entries). - The extremes must be black and white, and in the middle most possible colors are distributed.
- We need to apply a transition as smooth as possible from one color to another i.e. between color and color there has to be a very little difference in hue.
Suppose we have the palette of colors of MS Paint:
Since we do not want colors with opacity we can consider the first row of pixels, something like:
Now, the idea is to create an algorithm that divides the length of that range into n
equal parts, in order to maintain a consistency with the use of colors. For example, if we are using 2
colors we could imagine the following:
If we need 5
colors:
and so on.
Another (more viable) option is to use colorbrewer
PGFPlots library since it is very easy to have a range of colors, so I prefer this option (if you have another option you can post it, I also will be grateful).
I am fully aware of the creation of these two questions:
but them are adapted to plots, not arrows.
What I have done
MWE:
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\foreach \X in {0,...,5} {
\node[circle,draw,name=a\X] at (0,\X) {};
}
\foreach \X in {0,...,5} {
\node[circle,draw,name=b\X] at (1,\X) {};
}
\foreach \X in {0,...,5} {
\draw[-latex] (a\X) to (b\X);
}
\foreach \X in {0,...,5} {
\draw[-latex] (a\X) to (b\X);
}
\end{tikzpicture}
\end{document}
Here n=5
.
My idea is to use \definecolor{mycolor}{rgb}{[R],[G],[B]}
inside three loops, where each index is [R]
, [G]
and [B]
going from 0
to 255
. The problem is that I do not know how to nest them to produce a nice division nor do I know how to add that color to the arrow. I only tried to vary the first parameter in this way:
\foreach \Y in {1,...,255} {
\definecolor{currentcolor}{rgb}{0, 1, 1} % I need at least one color
\foreach \X in {0,...,5} { % I go through each arrow and add the color
\draw[-latex,currentcolor] (a\X) to (b\X);
\definecolor{currentcolor}{rgb}{\Y, 1, 1} % I recursively add the colors
}
}
However, this algorithm (which pretends to be recursive) does not do more than to add a single color to the arrows and it always go through the deeper loop without considering the other colors!
Each arrow must have a different color, as distributed as possible within a set of colors (in which this set must contain a high amount of gradient colors).
Is it possible to adapt something from Using ColorBrewer
in TikZ
and pgfplots
to use it in the MWE?
Thanks!!
(*) In practice I need between 30
to 50
arrows, hence, colors.