How do I draw a barber pole using tikz?











up vote
4
down vote

favorite












I have the following code to draw a number of colored lines.
Instead of having straight lines I would like to draw a barber pole containing the five colors in the thin stripes.



Note that I'm not looking for anything 3D, just diagonal stripes.
like so ///////



This would look something like this:



enter image description here



How do I do this?



documentclass{standalone}
usepackage{tikz}
%usetikzlibrary{...}
definecolor{pink}{RGB}{255,128,128}
definecolor{light-gray}{gray}{0.98}
definecolor{darkgreen}{RGB}{0,64,0}
definecolor{lightgray}{gray}{0.75}
definecolor{lightred}{RGB}{255,160,160}
definecolor{lightblue}{RGB}{200,200,255}
definecolor{lightgreen}{RGB}{170,255,170}
definecolor{lightyellow}{RGB}{255,255,160}
definecolor{pink}{RGB}{255,128,128}
definecolor{lightpurple}{RGB}{255,180,255}
definecolor{greenblue}{RGB}{180,255,255}
definecolor{lightorange}{RGB}{255,200,180}
definecolor{yellowgreen}{RGB}{230,230,180}
begin{document}
begin{tikzpicture}

defopacity{0.75}
defxcellsa{{{"2","1","0"},{"5","4","3"},{"8","7","6"}}}

defbitsencoding{{
{"","0","1","2","3","4","5","6","7","...","504","505","506","507","508","509","510","511"},
{"0:","0","1","0","1","0","1","0","1","...","0","1","0","1","0","1","0","1"},
{"1:","0","0","1","1","0","0","1","1","...","0","0","1","1","0","0","1","1"},
{"2:","0","0","0","0","1","1","1","1","...","0","0","0","0","1","1","1","1"},
{"...","...","","","","","","","","","","","","","","","",""},
{"8:","0","0","0","0","0","0","0","0","...","1","1","1","1","1","1","1","1"},
}}

%neighbor grid
draw[step=1,black, opacity=opacity, fill opacity=0] (0,0) grid ({3},{3});
draw[fill = lightred] (0,0) rectangle (1,1);
draw[fill = lightpurple] (0,1) rectangle (1,2);
draw[fill = lightblue] (0,2) rectangle (1,3);
draw[fill = lightorange] (1,0) rectangle (2,1);
draw[fill = white] (1,1) rectangle(2,2);
draw[fill = greenblue] (1,2) rectangle (2,3);
draw[fill = lightyellow] (2,0) rectangle (3,1);
draw[fill = yellowgreen] (2,1) rectangle (3,2);
draw[fill = lightgreen] (2,2) rectangle (3,3);

foreach xa in {2,1,0}
foreach ya in {2,1,0}
{
node[align=center] at ({xa+0.5},{ya+0.5}) {pgfmathparse{xcellsa[2-ya][xa]}pgfmathresult};
}

node at (1.5,3.5) {pixel positions};
node at (9.85,3.5) {encoding per constellation};
begin{scope}[xscale = 0.7, yscale=0.5]
fill[fill = lightgreen] (5,4) rectangle ({17+6},5);
fill[fill = greenblue] (5,3) rectangle ({17+6},4);
fill[fill = lightblue] (5,2) rectangle ({17+6},3);
%I want this part to be replaced with a barber pole containing the five colors
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fill[fill = yellowgreen] (5,1.8) rectangle ({17+6},2.0);
fill[fill = white] (5,1.6) rectangle ({17+6},1.8);
fill[fill = lightpurple] (5,1.4) rectangle ({17+6},1.6);
fill[fill = lightyellow] (5,1.2) rectangle ({17+6},1.4);
fill[fill = lightorange] (5,1) rectangle ({17+6},1.2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fill[fill = lightred] (5,0) rectangle ({17+6},1);
%bit encoding
foreach ya in {5,4,3,2,1,0}
foreach xa in {17,16,...,0}
{
node[align=center] at ({xa+5.50},{ya+0.5}) {pgfmathparse{bitsencoding[5-ya][xa]}pgfmathresult};
}
node[anchor=west] at (4.7,6.5) {pixel/constellation};
draw[thick,->,>=stealth] (5.43, 6.1) -- (5.43, 5.2);
draw[thick,->,>=stealth] (9.2, 6.5) -- (10.1, 6.5);

end{scope}
end{tikzpicture}
end{document}


EDIT

Here is the solution I came up with using @marmot's answer.



documentclass{standalone}
usepackage{tikz}
%usetikzlibrary{...}
definecolor{pink}{RGB}{255,128,128}
definecolor{light-gray}{gray}{0.98}
definecolor{darkgreen}{RGB}{0,64,0}
definecolor{lightgray}{gray}{0.90}
definecolor{lightred}{RGB}{255,160,160}
definecolor{lightblue}{RGB}{200,200,255}
definecolor{lightgreen}{RGB}{170,255,170}
definecolor{lightyellow}{RGB}{255,255,160}
definecolor{pink}{RGB}{255,128,128}
definecolor{lightpurple}{RGB}{255,180,255}
definecolor{greenblue}{RGB}{180,255,255}
definecolor{lightorange}{RGB}{255,200,180}
definecolor{yellowgreen}{RGB}{230,230,180}
begin{document}
begin{tikzpicture}

defopacity{0.75}
defxcellsa{{{"2","1","0"},{"5","4","3"},{"8","7","6"}}}

defbitsencoding{{
{"","0","1","2","3","4","5","6","7","...","504","505","506","507","508","509","510","511"},
{"0:","0","1","0","1","0","1","0","1","...","0","1","0","1","0","1","0","1"},
{"1:","0","0","1","1","0","0","1","1","...","0","0","1","1","0","0","1","1"},
{"2:","0","0","0","0","1","1","1","1","...","0","0","0","0","1","1","1","1"},
{"...","...","","","","","","","","","","","","","","","",""},
{"8:","0","0","0","0","0","0","0","0","...","1","1","1","1","1","1","1","1"},
}}

%neighbor grid
draw[step=1,black, opacity=opacity, fill opacity=0] (0,0) grid ({3},{3});
draw[fill = lightred] (0,0) rectangle (1,1);
draw[fill = lightpurple] (0,1) rectangle (1,2);
draw[fill = lightblue] (0,2) rectangle (1,3);
draw[fill = lightorange] (1,0) rectangle (2,1);
draw[fill = lightgray] (1,1) rectangle(2,2);
draw[fill = greenblue] (1,2) rectangle (2,3);
draw[fill = lightyellow] (2,0) rectangle (3,1);
draw[fill = yellowgreen] (2,1) rectangle (3,2);
draw[fill = lightgreen] (2,2) rectangle (3,3);

foreach xa in {2,1,0}
foreach ya in {2,1,0}
{
node[align=center] at ({xa+0.5},{ya+0.5}) {pgfmathparse{xcellsa[2-ya][xa]}pgfmathresult};
}


node at (1.5,3.5) {pixel positions};
node at (9.85,3.5) {encoding per constellation};
begin{scope}[xscale = 0.7, yscale=0.5]
fill[fill = lightgreen] (5,4) rectangle ({17+6},5);
fill[fill = greenblue] (5,3) rectangle ({17+6},4);
fill[fill = lightblue] (5,2) rectangle ({17+6},3);

%fill[fill = yellowgreen] (5,1.8) rectangle ({17+6},2.0);
%fill[fill = white] (5,1.6) rectangle ({17+6},1.8);
%fill[fill = lightpurple] (5,1.4) rectangle ({17+6},1.6);
%fill[fill = lightyellow] (5,1.2) rectangle ({17+6},1.4);
%fill[fill = lightorange] (5,1) rectangle ({17+6},1.2);
fill[fill = lightred] (5,0) rectangle ({17+6},1);
%bit encoding
foreach ya in {5,4,3,2,1,0}
foreach xa in {17,16,...,0}
{
node[align=center] at ({xa+5.50},{ya+0.5}) {pgfmathparse{bitsencoding[5-ya][xa]}pgfmathresult};
}
node[anchor=west] at (4.7,6.5) {pixel/constellation};
draw[thick,->,>=stealth] (5.43, 6.1) -- (5.43, 5.2);
draw[thick,->,>=stealth] (9.2, 6.5) -- (10.1, 6.5);

clip(5,1) rectangle ({17+6},2);
foreach Q in {0,1,2,3,4,5,6,7}
foreach X [count=Y] in
{yellowgreen,lightgray,lightpurple,lightyellow,lightorange}
{draw[color=X,line width=4mm] (Y*0.6+Q*3+1,0.1) -- ++(0.9,2.5);}
foreach ya in {1}
foreach xa in {17,16,...,0}
{
node[align=center] at ({xa+5.50},{ya+0.5}) {pgfmathparse{bitsencoding[5-ya][xa]}pgfmathresult};
}


end{scope}
end{tikzpicture}
end{document}









share|improve this question




















  • 3




    Hm, what is a barber pole? Can you add an image to your question?
    – Kurt
    Dec 2 at 17:56






  • 1




    I think this is one rotation away from side-by-side colorful rectangles.
    – Symbol 1
    Dec 2 at 18:35










  • Thanks for adding the screen shot! But now I am wondering what the relation between this and your code is. Do you want to use the barber pole as a background for the matrix in some way?
    – marmot
    Dec 2 at 18:53










  • @marmot, yes, its a background for the matrix. The part where it says ...
    – Johan
    Dec 2 at 23:37















up vote
4
down vote

favorite












I have the following code to draw a number of colored lines.
Instead of having straight lines I would like to draw a barber pole containing the five colors in the thin stripes.



Note that I'm not looking for anything 3D, just diagonal stripes.
like so ///////



This would look something like this:



enter image description here



How do I do this?



documentclass{standalone}
usepackage{tikz}
%usetikzlibrary{...}
definecolor{pink}{RGB}{255,128,128}
definecolor{light-gray}{gray}{0.98}
definecolor{darkgreen}{RGB}{0,64,0}
definecolor{lightgray}{gray}{0.75}
definecolor{lightred}{RGB}{255,160,160}
definecolor{lightblue}{RGB}{200,200,255}
definecolor{lightgreen}{RGB}{170,255,170}
definecolor{lightyellow}{RGB}{255,255,160}
definecolor{pink}{RGB}{255,128,128}
definecolor{lightpurple}{RGB}{255,180,255}
definecolor{greenblue}{RGB}{180,255,255}
definecolor{lightorange}{RGB}{255,200,180}
definecolor{yellowgreen}{RGB}{230,230,180}
begin{document}
begin{tikzpicture}

defopacity{0.75}
defxcellsa{{{"2","1","0"},{"5","4","3"},{"8","7","6"}}}

defbitsencoding{{
{"","0","1","2","3","4","5","6","7","...","504","505","506","507","508","509","510","511"},
{"0:","0","1","0","1","0","1","0","1","...","0","1","0","1","0","1","0","1"},
{"1:","0","0","1","1","0","0","1","1","...","0","0","1","1","0","0","1","1"},
{"2:","0","0","0","0","1","1","1","1","...","0","0","0","0","1","1","1","1"},
{"...","...","","","","","","","","","","","","","","","",""},
{"8:","0","0","0","0","0","0","0","0","...","1","1","1","1","1","1","1","1"},
}}

%neighbor grid
draw[step=1,black, opacity=opacity, fill opacity=0] (0,0) grid ({3},{3});
draw[fill = lightred] (0,0) rectangle (1,1);
draw[fill = lightpurple] (0,1) rectangle (1,2);
draw[fill = lightblue] (0,2) rectangle (1,3);
draw[fill = lightorange] (1,0) rectangle (2,1);
draw[fill = white] (1,1) rectangle(2,2);
draw[fill = greenblue] (1,2) rectangle (2,3);
draw[fill = lightyellow] (2,0) rectangle (3,1);
draw[fill = yellowgreen] (2,1) rectangle (3,2);
draw[fill = lightgreen] (2,2) rectangle (3,3);

foreach xa in {2,1,0}
foreach ya in {2,1,0}
{
node[align=center] at ({xa+0.5},{ya+0.5}) {pgfmathparse{xcellsa[2-ya][xa]}pgfmathresult};
}

node at (1.5,3.5) {pixel positions};
node at (9.85,3.5) {encoding per constellation};
begin{scope}[xscale = 0.7, yscale=0.5]
fill[fill = lightgreen] (5,4) rectangle ({17+6},5);
fill[fill = greenblue] (5,3) rectangle ({17+6},4);
fill[fill = lightblue] (5,2) rectangle ({17+6},3);
%I want this part to be replaced with a barber pole containing the five colors
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fill[fill = yellowgreen] (5,1.8) rectangle ({17+6},2.0);
fill[fill = white] (5,1.6) rectangle ({17+6},1.8);
fill[fill = lightpurple] (5,1.4) rectangle ({17+6},1.6);
fill[fill = lightyellow] (5,1.2) rectangle ({17+6},1.4);
fill[fill = lightorange] (5,1) rectangle ({17+6},1.2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fill[fill = lightred] (5,0) rectangle ({17+6},1);
%bit encoding
foreach ya in {5,4,3,2,1,0}
foreach xa in {17,16,...,0}
{
node[align=center] at ({xa+5.50},{ya+0.5}) {pgfmathparse{bitsencoding[5-ya][xa]}pgfmathresult};
}
node[anchor=west] at (4.7,6.5) {pixel/constellation};
draw[thick,->,>=stealth] (5.43, 6.1) -- (5.43, 5.2);
draw[thick,->,>=stealth] (9.2, 6.5) -- (10.1, 6.5);

end{scope}
end{tikzpicture}
end{document}


EDIT

Here is the solution I came up with using @marmot's answer.



documentclass{standalone}
usepackage{tikz}
%usetikzlibrary{...}
definecolor{pink}{RGB}{255,128,128}
definecolor{light-gray}{gray}{0.98}
definecolor{darkgreen}{RGB}{0,64,0}
definecolor{lightgray}{gray}{0.90}
definecolor{lightred}{RGB}{255,160,160}
definecolor{lightblue}{RGB}{200,200,255}
definecolor{lightgreen}{RGB}{170,255,170}
definecolor{lightyellow}{RGB}{255,255,160}
definecolor{pink}{RGB}{255,128,128}
definecolor{lightpurple}{RGB}{255,180,255}
definecolor{greenblue}{RGB}{180,255,255}
definecolor{lightorange}{RGB}{255,200,180}
definecolor{yellowgreen}{RGB}{230,230,180}
begin{document}
begin{tikzpicture}

defopacity{0.75}
defxcellsa{{{"2","1","0"},{"5","4","3"},{"8","7","6"}}}

defbitsencoding{{
{"","0","1","2","3","4","5","6","7","...","504","505","506","507","508","509","510","511"},
{"0:","0","1","0","1","0","1","0","1","...","0","1","0","1","0","1","0","1"},
{"1:","0","0","1","1","0","0","1","1","...","0","0","1","1","0","0","1","1"},
{"2:","0","0","0","0","1","1","1","1","...","0","0","0","0","1","1","1","1"},
{"...","...","","","","","","","","","","","","","","","",""},
{"8:","0","0","0","0","0","0","0","0","...","1","1","1","1","1","1","1","1"},
}}

%neighbor grid
draw[step=1,black, opacity=opacity, fill opacity=0] (0,0) grid ({3},{3});
draw[fill = lightred] (0,0) rectangle (1,1);
draw[fill = lightpurple] (0,1) rectangle (1,2);
draw[fill = lightblue] (0,2) rectangle (1,3);
draw[fill = lightorange] (1,0) rectangle (2,1);
draw[fill = lightgray] (1,1) rectangle(2,2);
draw[fill = greenblue] (1,2) rectangle (2,3);
draw[fill = lightyellow] (2,0) rectangle (3,1);
draw[fill = yellowgreen] (2,1) rectangle (3,2);
draw[fill = lightgreen] (2,2) rectangle (3,3);

foreach xa in {2,1,0}
foreach ya in {2,1,0}
{
node[align=center] at ({xa+0.5},{ya+0.5}) {pgfmathparse{xcellsa[2-ya][xa]}pgfmathresult};
}


node at (1.5,3.5) {pixel positions};
node at (9.85,3.5) {encoding per constellation};
begin{scope}[xscale = 0.7, yscale=0.5]
fill[fill = lightgreen] (5,4) rectangle ({17+6},5);
fill[fill = greenblue] (5,3) rectangle ({17+6},4);
fill[fill = lightblue] (5,2) rectangle ({17+6},3);

%fill[fill = yellowgreen] (5,1.8) rectangle ({17+6},2.0);
%fill[fill = white] (5,1.6) rectangle ({17+6},1.8);
%fill[fill = lightpurple] (5,1.4) rectangle ({17+6},1.6);
%fill[fill = lightyellow] (5,1.2) rectangle ({17+6},1.4);
%fill[fill = lightorange] (5,1) rectangle ({17+6},1.2);
fill[fill = lightred] (5,0) rectangle ({17+6},1);
%bit encoding
foreach ya in {5,4,3,2,1,0}
foreach xa in {17,16,...,0}
{
node[align=center] at ({xa+5.50},{ya+0.5}) {pgfmathparse{bitsencoding[5-ya][xa]}pgfmathresult};
}
node[anchor=west] at (4.7,6.5) {pixel/constellation};
draw[thick,->,>=stealth] (5.43, 6.1) -- (5.43, 5.2);
draw[thick,->,>=stealth] (9.2, 6.5) -- (10.1, 6.5);

clip(5,1) rectangle ({17+6},2);
foreach Q in {0,1,2,3,4,5,6,7}
foreach X [count=Y] in
{yellowgreen,lightgray,lightpurple,lightyellow,lightorange}
{draw[color=X,line width=4mm] (Y*0.6+Q*3+1,0.1) -- ++(0.9,2.5);}
foreach ya in {1}
foreach xa in {17,16,...,0}
{
node[align=center] at ({xa+5.50},{ya+0.5}) {pgfmathparse{bitsencoding[5-ya][xa]}pgfmathresult};
}


end{scope}
end{tikzpicture}
end{document}









share|improve this question




















  • 3




    Hm, what is a barber pole? Can you add an image to your question?
    – Kurt
    Dec 2 at 17:56






  • 1




    I think this is one rotation away from side-by-side colorful rectangles.
    – Symbol 1
    Dec 2 at 18:35










  • Thanks for adding the screen shot! But now I am wondering what the relation between this and your code is. Do you want to use the barber pole as a background for the matrix in some way?
    – marmot
    Dec 2 at 18:53










  • @marmot, yes, its a background for the matrix. The part where it says ...
    – Johan
    Dec 2 at 23:37













up vote
4
down vote

favorite









up vote
4
down vote

favorite











I have the following code to draw a number of colored lines.
Instead of having straight lines I would like to draw a barber pole containing the five colors in the thin stripes.



Note that I'm not looking for anything 3D, just diagonal stripes.
like so ///////



This would look something like this:



enter image description here



How do I do this?



documentclass{standalone}
usepackage{tikz}
%usetikzlibrary{...}
definecolor{pink}{RGB}{255,128,128}
definecolor{light-gray}{gray}{0.98}
definecolor{darkgreen}{RGB}{0,64,0}
definecolor{lightgray}{gray}{0.75}
definecolor{lightred}{RGB}{255,160,160}
definecolor{lightblue}{RGB}{200,200,255}
definecolor{lightgreen}{RGB}{170,255,170}
definecolor{lightyellow}{RGB}{255,255,160}
definecolor{pink}{RGB}{255,128,128}
definecolor{lightpurple}{RGB}{255,180,255}
definecolor{greenblue}{RGB}{180,255,255}
definecolor{lightorange}{RGB}{255,200,180}
definecolor{yellowgreen}{RGB}{230,230,180}
begin{document}
begin{tikzpicture}

defopacity{0.75}
defxcellsa{{{"2","1","0"},{"5","4","3"},{"8","7","6"}}}

defbitsencoding{{
{"","0","1","2","3","4","5","6","7","...","504","505","506","507","508","509","510","511"},
{"0:","0","1","0","1","0","1","0","1","...","0","1","0","1","0","1","0","1"},
{"1:","0","0","1","1","0","0","1","1","...","0","0","1","1","0","0","1","1"},
{"2:","0","0","0","0","1","1","1","1","...","0","0","0","0","1","1","1","1"},
{"...","...","","","","","","","","","","","","","","","",""},
{"8:","0","0","0","0","0","0","0","0","...","1","1","1","1","1","1","1","1"},
}}

%neighbor grid
draw[step=1,black, opacity=opacity, fill opacity=0] (0,0) grid ({3},{3});
draw[fill = lightred] (0,0) rectangle (1,1);
draw[fill = lightpurple] (0,1) rectangle (1,2);
draw[fill = lightblue] (0,2) rectangle (1,3);
draw[fill = lightorange] (1,0) rectangle (2,1);
draw[fill = white] (1,1) rectangle(2,2);
draw[fill = greenblue] (1,2) rectangle (2,3);
draw[fill = lightyellow] (2,0) rectangle (3,1);
draw[fill = yellowgreen] (2,1) rectangle (3,2);
draw[fill = lightgreen] (2,2) rectangle (3,3);

foreach xa in {2,1,0}
foreach ya in {2,1,0}
{
node[align=center] at ({xa+0.5},{ya+0.5}) {pgfmathparse{xcellsa[2-ya][xa]}pgfmathresult};
}

node at (1.5,3.5) {pixel positions};
node at (9.85,3.5) {encoding per constellation};
begin{scope}[xscale = 0.7, yscale=0.5]
fill[fill = lightgreen] (5,4) rectangle ({17+6},5);
fill[fill = greenblue] (5,3) rectangle ({17+6},4);
fill[fill = lightblue] (5,2) rectangle ({17+6},3);
%I want this part to be replaced with a barber pole containing the five colors
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fill[fill = yellowgreen] (5,1.8) rectangle ({17+6},2.0);
fill[fill = white] (5,1.6) rectangle ({17+6},1.8);
fill[fill = lightpurple] (5,1.4) rectangle ({17+6},1.6);
fill[fill = lightyellow] (5,1.2) rectangle ({17+6},1.4);
fill[fill = lightorange] (5,1) rectangle ({17+6},1.2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fill[fill = lightred] (5,0) rectangle ({17+6},1);
%bit encoding
foreach ya in {5,4,3,2,1,0}
foreach xa in {17,16,...,0}
{
node[align=center] at ({xa+5.50},{ya+0.5}) {pgfmathparse{bitsencoding[5-ya][xa]}pgfmathresult};
}
node[anchor=west] at (4.7,6.5) {pixel/constellation};
draw[thick,->,>=stealth] (5.43, 6.1) -- (5.43, 5.2);
draw[thick,->,>=stealth] (9.2, 6.5) -- (10.1, 6.5);

end{scope}
end{tikzpicture}
end{document}


EDIT

Here is the solution I came up with using @marmot's answer.



documentclass{standalone}
usepackage{tikz}
%usetikzlibrary{...}
definecolor{pink}{RGB}{255,128,128}
definecolor{light-gray}{gray}{0.98}
definecolor{darkgreen}{RGB}{0,64,0}
definecolor{lightgray}{gray}{0.90}
definecolor{lightred}{RGB}{255,160,160}
definecolor{lightblue}{RGB}{200,200,255}
definecolor{lightgreen}{RGB}{170,255,170}
definecolor{lightyellow}{RGB}{255,255,160}
definecolor{pink}{RGB}{255,128,128}
definecolor{lightpurple}{RGB}{255,180,255}
definecolor{greenblue}{RGB}{180,255,255}
definecolor{lightorange}{RGB}{255,200,180}
definecolor{yellowgreen}{RGB}{230,230,180}
begin{document}
begin{tikzpicture}

defopacity{0.75}
defxcellsa{{{"2","1","0"},{"5","4","3"},{"8","7","6"}}}

defbitsencoding{{
{"","0","1","2","3","4","5","6","7","...","504","505","506","507","508","509","510","511"},
{"0:","0","1","0","1","0","1","0","1","...","0","1","0","1","0","1","0","1"},
{"1:","0","0","1","1","0","0","1","1","...","0","0","1","1","0","0","1","1"},
{"2:","0","0","0","0","1","1","1","1","...","0","0","0","0","1","1","1","1"},
{"...","...","","","","","","","","","","","","","","","",""},
{"8:","0","0","0","0","0","0","0","0","...","1","1","1","1","1","1","1","1"},
}}

%neighbor grid
draw[step=1,black, opacity=opacity, fill opacity=0] (0,0) grid ({3},{3});
draw[fill = lightred] (0,0) rectangle (1,1);
draw[fill = lightpurple] (0,1) rectangle (1,2);
draw[fill = lightblue] (0,2) rectangle (1,3);
draw[fill = lightorange] (1,0) rectangle (2,1);
draw[fill = lightgray] (1,1) rectangle(2,2);
draw[fill = greenblue] (1,2) rectangle (2,3);
draw[fill = lightyellow] (2,0) rectangle (3,1);
draw[fill = yellowgreen] (2,1) rectangle (3,2);
draw[fill = lightgreen] (2,2) rectangle (3,3);

foreach xa in {2,1,0}
foreach ya in {2,1,0}
{
node[align=center] at ({xa+0.5},{ya+0.5}) {pgfmathparse{xcellsa[2-ya][xa]}pgfmathresult};
}


node at (1.5,3.5) {pixel positions};
node at (9.85,3.5) {encoding per constellation};
begin{scope}[xscale = 0.7, yscale=0.5]
fill[fill = lightgreen] (5,4) rectangle ({17+6},5);
fill[fill = greenblue] (5,3) rectangle ({17+6},4);
fill[fill = lightblue] (5,2) rectangle ({17+6},3);

%fill[fill = yellowgreen] (5,1.8) rectangle ({17+6},2.0);
%fill[fill = white] (5,1.6) rectangle ({17+6},1.8);
%fill[fill = lightpurple] (5,1.4) rectangle ({17+6},1.6);
%fill[fill = lightyellow] (5,1.2) rectangle ({17+6},1.4);
%fill[fill = lightorange] (5,1) rectangle ({17+6},1.2);
fill[fill = lightred] (5,0) rectangle ({17+6},1);
%bit encoding
foreach ya in {5,4,3,2,1,0}
foreach xa in {17,16,...,0}
{
node[align=center] at ({xa+5.50},{ya+0.5}) {pgfmathparse{bitsencoding[5-ya][xa]}pgfmathresult};
}
node[anchor=west] at (4.7,6.5) {pixel/constellation};
draw[thick,->,>=stealth] (5.43, 6.1) -- (5.43, 5.2);
draw[thick,->,>=stealth] (9.2, 6.5) -- (10.1, 6.5);

clip(5,1) rectangle ({17+6},2);
foreach Q in {0,1,2,3,4,5,6,7}
foreach X [count=Y] in
{yellowgreen,lightgray,lightpurple,lightyellow,lightorange}
{draw[color=X,line width=4mm] (Y*0.6+Q*3+1,0.1) -- ++(0.9,2.5);}
foreach ya in {1}
foreach xa in {17,16,...,0}
{
node[align=center] at ({xa+5.50},{ya+0.5}) {pgfmathparse{bitsencoding[5-ya][xa]}pgfmathresult};
}


end{scope}
end{tikzpicture}
end{document}









share|improve this question















I have the following code to draw a number of colored lines.
Instead of having straight lines I would like to draw a barber pole containing the five colors in the thin stripes.



Note that I'm not looking for anything 3D, just diagonal stripes.
like so ///////



This would look something like this:



enter image description here



How do I do this?



documentclass{standalone}
usepackage{tikz}
%usetikzlibrary{...}
definecolor{pink}{RGB}{255,128,128}
definecolor{light-gray}{gray}{0.98}
definecolor{darkgreen}{RGB}{0,64,0}
definecolor{lightgray}{gray}{0.75}
definecolor{lightred}{RGB}{255,160,160}
definecolor{lightblue}{RGB}{200,200,255}
definecolor{lightgreen}{RGB}{170,255,170}
definecolor{lightyellow}{RGB}{255,255,160}
definecolor{pink}{RGB}{255,128,128}
definecolor{lightpurple}{RGB}{255,180,255}
definecolor{greenblue}{RGB}{180,255,255}
definecolor{lightorange}{RGB}{255,200,180}
definecolor{yellowgreen}{RGB}{230,230,180}
begin{document}
begin{tikzpicture}

defopacity{0.75}
defxcellsa{{{"2","1","0"},{"5","4","3"},{"8","7","6"}}}

defbitsencoding{{
{"","0","1","2","3","4","5","6","7","...","504","505","506","507","508","509","510","511"},
{"0:","0","1","0","1","0","1","0","1","...","0","1","0","1","0","1","0","1"},
{"1:","0","0","1","1","0","0","1","1","...","0","0","1","1","0","0","1","1"},
{"2:","0","0","0","0","1","1","1","1","...","0","0","0","0","1","1","1","1"},
{"...","...","","","","","","","","","","","","","","","",""},
{"8:","0","0","0","0","0","0","0","0","...","1","1","1","1","1","1","1","1"},
}}

%neighbor grid
draw[step=1,black, opacity=opacity, fill opacity=0] (0,0) grid ({3},{3});
draw[fill = lightred] (0,0) rectangle (1,1);
draw[fill = lightpurple] (0,1) rectangle (1,2);
draw[fill = lightblue] (0,2) rectangle (1,3);
draw[fill = lightorange] (1,0) rectangle (2,1);
draw[fill = white] (1,1) rectangle(2,2);
draw[fill = greenblue] (1,2) rectangle (2,3);
draw[fill = lightyellow] (2,0) rectangle (3,1);
draw[fill = yellowgreen] (2,1) rectangle (3,2);
draw[fill = lightgreen] (2,2) rectangle (3,3);

foreach xa in {2,1,0}
foreach ya in {2,1,0}
{
node[align=center] at ({xa+0.5},{ya+0.5}) {pgfmathparse{xcellsa[2-ya][xa]}pgfmathresult};
}

node at (1.5,3.5) {pixel positions};
node at (9.85,3.5) {encoding per constellation};
begin{scope}[xscale = 0.7, yscale=0.5]
fill[fill = lightgreen] (5,4) rectangle ({17+6},5);
fill[fill = greenblue] (5,3) rectangle ({17+6},4);
fill[fill = lightblue] (5,2) rectangle ({17+6},3);
%I want this part to be replaced with a barber pole containing the five colors
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fill[fill = yellowgreen] (5,1.8) rectangle ({17+6},2.0);
fill[fill = white] (5,1.6) rectangle ({17+6},1.8);
fill[fill = lightpurple] (5,1.4) rectangle ({17+6},1.6);
fill[fill = lightyellow] (5,1.2) rectangle ({17+6},1.4);
fill[fill = lightorange] (5,1) rectangle ({17+6},1.2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fill[fill = lightred] (5,0) rectangle ({17+6},1);
%bit encoding
foreach ya in {5,4,3,2,1,0}
foreach xa in {17,16,...,0}
{
node[align=center] at ({xa+5.50},{ya+0.5}) {pgfmathparse{bitsencoding[5-ya][xa]}pgfmathresult};
}
node[anchor=west] at (4.7,6.5) {pixel/constellation};
draw[thick,->,>=stealth] (5.43, 6.1) -- (5.43, 5.2);
draw[thick,->,>=stealth] (9.2, 6.5) -- (10.1, 6.5);

end{scope}
end{tikzpicture}
end{document}


EDIT

Here is the solution I came up with using @marmot's answer.



documentclass{standalone}
usepackage{tikz}
%usetikzlibrary{...}
definecolor{pink}{RGB}{255,128,128}
definecolor{light-gray}{gray}{0.98}
definecolor{darkgreen}{RGB}{0,64,0}
definecolor{lightgray}{gray}{0.90}
definecolor{lightred}{RGB}{255,160,160}
definecolor{lightblue}{RGB}{200,200,255}
definecolor{lightgreen}{RGB}{170,255,170}
definecolor{lightyellow}{RGB}{255,255,160}
definecolor{pink}{RGB}{255,128,128}
definecolor{lightpurple}{RGB}{255,180,255}
definecolor{greenblue}{RGB}{180,255,255}
definecolor{lightorange}{RGB}{255,200,180}
definecolor{yellowgreen}{RGB}{230,230,180}
begin{document}
begin{tikzpicture}

defopacity{0.75}
defxcellsa{{{"2","1","0"},{"5","4","3"},{"8","7","6"}}}

defbitsencoding{{
{"","0","1","2","3","4","5","6","7","...","504","505","506","507","508","509","510","511"},
{"0:","0","1","0","1","0","1","0","1","...","0","1","0","1","0","1","0","1"},
{"1:","0","0","1","1","0","0","1","1","...","0","0","1","1","0","0","1","1"},
{"2:","0","0","0","0","1","1","1","1","...","0","0","0","0","1","1","1","1"},
{"...","...","","","","","","","","","","","","","","","",""},
{"8:","0","0","0","0","0","0","0","0","...","1","1","1","1","1","1","1","1"},
}}

%neighbor grid
draw[step=1,black, opacity=opacity, fill opacity=0] (0,0) grid ({3},{3});
draw[fill = lightred] (0,0) rectangle (1,1);
draw[fill = lightpurple] (0,1) rectangle (1,2);
draw[fill = lightblue] (0,2) rectangle (1,3);
draw[fill = lightorange] (1,0) rectangle (2,1);
draw[fill = lightgray] (1,1) rectangle(2,2);
draw[fill = greenblue] (1,2) rectangle (2,3);
draw[fill = lightyellow] (2,0) rectangle (3,1);
draw[fill = yellowgreen] (2,1) rectangle (3,2);
draw[fill = lightgreen] (2,2) rectangle (3,3);

foreach xa in {2,1,0}
foreach ya in {2,1,0}
{
node[align=center] at ({xa+0.5},{ya+0.5}) {pgfmathparse{xcellsa[2-ya][xa]}pgfmathresult};
}


node at (1.5,3.5) {pixel positions};
node at (9.85,3.5) {encoding per constellation};
begin{scope}[xscale = 0.7, yscale=0.5]
fill[fill = lightgreen] (5,4) rectangle ({17+6},5);
fill[fill = greenblue] (5,3) rectangle ({17+6},4);
fill[fill = lightblue] (5,2) rectangle ({17+6},3);

%fill[fill = yellowgreen] (5,1.8) rectangle ({17+6},2.0);
%fill[fill = white] (5,1.6) rectangle ({17+6},1.8);
%fill[fill = lightpurple] (5,1.4) rectangle ({17+6},1.6);
%fill[fill = lightyellow] (5,1.2) rectangle ({17+6},1.4);
%fill[fill = lightorange] (5,1) rectangle ({17+6},1.2);
fill[fill = lightred] (5,0) rectangle ({17+6},1);
%bit encoding
foreach ya in {5,4,3,2,1,0}
foreach xa in {17,16,...,0}
{
node[align=center] at ({xa+5.50},{ya+0.5}) {pgfmathparse{bitsencoding[5-ya][xa]}pgfmathresult};
}
node[anchor=west] at (4.7,6.5) {pixel/constellation};
draw[thick,->,>=stealth] (5.43, 6.1) -- (5.43, 5.2);
draw[thick,->,>=stealth] (9.2, 6.5) -- (10.1, 6.5);

clip(5,1) rectangle ({17+6},2);
foreach Q in {0,1,2,3,4,5,6,7}
foreach X [count=Y] in
{yellowgreen,lightgray,lightpurple,lightyellow,lightorange}
{draw[color=X,line width=4mm] (Y*0.6+Q*3+1,0.1) -- ++(0.9,2.5);}
foreach ya in {1}
foreach xa in {17,16,...,0}
{
node[align=center] at ({xa+5.50},{ya+0.5}) {pgfmathparse{bitsencoding[5-ya][xa]}pgfmathresult};
}


end{scope}
end{tikzpicture}
end{document}






tikz-pgf






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 2 at 23:40

























asked Dec 2 at 17:01









Johan

1737




1737








  • 3




    Hm, what is a barber pole? Can you add an image to your question?
    – Kurt
    Dec 2 at 17:56






  • 1




    I think this is one rotation away from side-by-side colorful rectangles.
    – Symbol 1
    Dec 2 at 18:35










  • Thanks for adding the screen shot! But now I am wondering what the relation between this and your code is. Do you want to use the barber pole as a background for the matrix in some way?
    – marmot
    Dec 2 at 18:53










  • @marmot, yes, its a background for the matrix. The part where it says ...
    – Johan
    Dec 2 at 23:37














  • 3




    Hm, what is a barber pole? Can you add an image to your question?
    – Kurt
    Dec 2 at 17:56






  • 1




    I think this is one rotation away from side-by-side colorful rectangles.
    – Symbol 1
    Dec 2 at 18:35










  • Thanks for adding the screen shot! But now I am wondering what the relation between this and your code is. Do you want to use the barber pole as a background for the matrix in some way?
    – marmot
    Dec 2 at 18:53










  • @marmot, yes, its a background for the matrix. The part where it says ...
    – Johan
    Dec 2 at 23:37








3




3




Hm, what is a barber pole? Can you add an image to your question?
– Kurt
Dec 2 at 17:56




Hm, what is a barber pole? Can you add an image to your question?
– Kurt
Dec 2 at 17:56




1




1




I think this is one rotation away from side-by-side colorful rectangles.
– Symbol 1
Dec 2 at 18:35




I think this is one rotation away from side-by-side colorful rectangles.
– Symbol 1
Dec 2 at 18:35












Thanks for adding the screen shot! But now I am wondering what the relation between this and your code is. Do you want to use the barber pole as a background for the matrix in some way?
– marmot
Dec 2 at 18:53




Thanks for adding the screen shot! But now I am wondering what the relation between this and your code is. Do you want to use the barber pole as a background for the matrix in some way?
– marmot
Dec 2 at 18:53












@marmot, yes, its a background for the matrix. The part where it says ...
– Johan
Dec 2 at 23:37




@marmot, yes, its a background for the matrix. The part where it says ...
– Johan
Dec 2 at 23:37










1 Answer
1






active

oldest

votes

















up vote
7
down vote



accepted










It is absolutely straightforward to achieve something of this sort. Notice, however, that the only thing I am using from your nice MWE are some colors. This is because I do not know what role the barber pole should play.



documentclass[tikz,border=3.14mm]{standalone}
definecolor{pink}{RGB}{255,128,128}
definecolor{light-gray}{gray}{0.98}
definecolor{darkgreen}{RGB}{0,64,0}
definecolor{lightgray}{gray}{0.75}
definecolor{lightred}{RGB}{255,160,160}
definecolor{lightblue}{RGB}{200,200,255}
definecolor{lightgreen}{RGB}{170,255,170}
definecolor{lightyellow}{RGB}{255,255,160}
definecolor{pink}{RGB}{255,128,128}
definecolor{lightpurple}{RGB}{255,180,255}
definecolor{greenblue}{RGB}{180,255,255}
definecolor{lightorange}{RGB}{255,200,180}
definecolor{yellowgreen}{RGB}{230,230,180}
begin{document}
begin{tikzpicture}
clip(0,0) rectangle (2.5,1);
foreach X [count=Y] in
{pink,darkgreen,lightred,lightblue,lightgreen,lightyellow,pink,lightpurple}
{draw[color=X,line width=4mm] (Y*4mm-8mm,-0.1) -- ++(0.5,1.2);}
end{tikzpicture}
end{document}


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: 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%2f462830%2fhow-do-i-draw-a-barber-pole-using-tikz%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








    up vote
    7
    down vote



    accepted










    It is absolutely straightforward to achieve something of this sort. Notice, however, that the only thing I am using from your nice MWE are some colors. This is because I do not know what role the barber pole should play.



    documentclass[tikz,border=3.14mm]{standalone}
    definecolor{pink}{RGB}{255,128,128}
    definecolor{light-gray}{gray}{0.98}
    definecolor{darkgreen}{RGB}{0,64,0}
    definecolor{lightgray}{gray}{0.75}
    definecolor{lightred}{RGB}{255,160,160}
    definecolor{lightblue}{RGB}{200,200,255}
    definecolor{lightgreen}{RGB}{170,255,170}
    definecolor{lightyellow}{RGB}{255,255,160}
    definecolor{pink}{RGB}{255,128,128}
    definecolor{lightpurple}{RGB}{255,180,255}
    definecolor{greenblue}{RGB}{180,255,255}
    definecolor{lightorange}{RGB}{255,200,180}
    definecolor{yellowgreen}{RGB}{230,230,180}
    begin{document}
    begin{tikzpicture}
    clip(0,0) rectangle (2.5,1);
    foreach X [count=Y] in
    {pink,darkgreen,lightred,lightblue,lightgreen,lightyellow,pink,lightpurple}
    {draw[color=X,line width=4mm] (Y*4mm-8mm,-0.1) -- ++(0.5,1.2);}
    end{tikzpicture}
    end{document}


    enter image description here






    share|improve this answer

























      up vote
      7
      down vote



      accepted










      It is absolutely straightforward to achieve something of this sort. Notice, however, that the only thing I am using from your nice MWE are some colors. This is because I do not know what role the barber pole should play.



      documentclass[tikz,border=3.14mm]{standalone}
      definecolor{pink}{RGB}{255,128,128}
      definecolor{light-gray}{gray}{0.98}
      definecolor{darkgreen}{RGB}{0,64,0}
      definecolor{lightgray}{gray}{0.75}
      definecolor{lightred}{RGB}{255,160,160}
      definecolor{lightblue}{RGB}{200,200,255}
      definecolor{lightgreen}{RGB}{170,255,170}
      definecolor{lightyellow}{RGB}{255,255,160}
      definecolor{pink}{RGB}{255,128,128}
      definecolor{lightpurple}{RGB}{255,180,255}
      definecolor{greenblue}{RGB}{180,255,255}
      definecolor{lightorange}{RGB}{255,200,180}
      definecolor{yellowgreen}{RGB}{230,230,180}
      begin{document}
      begin{tikzpicture}
      clip(0,0) rectangle (2.5,1);
      foreach X [count=Y] in
      {pink,darkgreen,lightred,lightblue,lightgreen,lightyellow,pink,lightpurple}
      {draw[color=X,line width=4mm] (Y*4mm-8mm,-0.1) -- ++(0.5,1.2);}
      end{tikzpicture}
      end{document}


      enter image description here






      share|improve this answer























        up vote
        7
        down vote



        accepted







        up vote
        7
        down vote



        accepted






        It is absolutely straightforward to achieve something of this sort. Notice, however, that the only thing I am using from your nice MWE are some colors. This is because I do not know what role the barber pole should play.



        documentclass[tikz,border=3.14mm]{standalone}
        definecolor{pink}{RGB}{255,128,128}
        definecolor{light-gray}{gray}{0.98}
        definecolor{darkgreen}{RGB}{0,64,0}
        definecolor{lightgray}{gray}{0.75}
        definecolor{lightred}{RGB}{255,160,160}
        definecolor{lightblue}{RGB}{200,200,255}
        definecolor{lightgreen}{RGB}{170,255,170}
        definecolor{lightyellow}{RGB}{255,255,160}
        definecolor{pink}{RGB}{255,128,128}
        definecolor{lightpurple}{RGB}{255,180,255}
        definecolor{greenblue}{RGB}{180,255,255}
        definecolor{lightorange}{RGB}{255,200,180}
        definecolor{yellowgreen}{RGB}{230,230,180}
        begin{document}
        begin{tikzpicture}
        clip(0,0) rectangle (2.5,1);
        foreach X [count=Y] in
        {pink,darkgreen,lightred,lightblue,lightgreen,lightyellow,pink,lightpurple}
        {draw[color=X,line width=4mm] (Y*4mm-8mm,-0.1) -- ++(0.5,1.2);}
        end{tikzpicture}
        end{document}


        enter image description here






        share|improve this answer












        It is absolutely straightforward to achieve something of this sort. Notice, however, that the only thing I am using from your nice MWE are some colors. This is because I do not know what role the barber pole should play.



        documentclass[tikz,border=3.14mm]{standalone}
        definecolor{pink}{RGB}{255,128,128}
        definecolor{light-gray}{gray}{0.98}
        definecolor{darkgreen}{RGB}{0,64,0}
        definecolor{lightgray}{gray}{0.75}
        definecolor{lightred}{RGB}{255,160,160}
        definecolor{lightblue}{RGB}{200,200,255}
        definecolor{lightgreen}{RGB}{170,255,170}
        definecolor{lightyellow}{RGB}{255,255,160}
        definecolor{pink}{RGB}{255,128,128}
        definecolor{lightpurple}{RGB}{255,180,255}
        definecolor{greenblue}{RGB}{180,255,255}
        definecolor{lightorange}{RGB}{255,200,180}
        definecolor{yellowgreen}{RGB}{230,230,180}
        begin{document}
        begin{tikzpicture}
        clip(0,0) rectangle (2.5,1);
        foreach X [count=Y] in
        {pink,darkgreen,lightred,lightblue,lightgreen,lightyellow,pink,lightpurple}
        {draw[color=X,line width=4mm] (Y*4mm-8mm,-0.1) -- ++(0.5,1.2);}
        end{tikzpicture}
        end{document}


        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 2 at 19:00









        marmot

        83.8k493178




        83.8k493178






























            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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2f462830%2fhow-do-i-draw-a-barber-pole-using-tikz%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

            Quarter-circle Tiles

            build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

            Mont Emei